From rodney_bates at lcwb.coop Wed Nov 22 17:57:22 2017 From: rodney_bates at lcwb.coop (Rodney M. Bates) Date: Wed, 22 Nov 2017 10:57:22 -0600 Subject: [M3devel] [modula3/cm3] f77161: Fix CG internal error, when passing bitpacked arra... In-Reply-To: <5a14aa3c39719_7e393fe79191bc4415938a@hookshot-fe5-cp1-prd.iad.github.net.mail> References: <5a14aa3c39719_7e393fe79191bc4415938a@hookshot-fe5-cp1-prd.iad.github.net.mail> Message-ID: <83d18ef9-f1b9-e3c7-16c7-18851bb6b393@lcwb.coop> This fix contains a line of endian-dependent code. I have no big endian machine to test this on. It would be nice of somebody could test it on one. Just compile and run the case below and see that the compile succeeds and it produces the output even further below. ------------------------------------------------------------------------------------ Test program: MODULE Main ; IMPORT Fmt ; IMPORT Stdio ; IMPORT Thread ; IMPORT Wr ; VAR GWr : Wr . T ; PROCEDURE WLI ( Tag : TEXT ; J : INTEGER ) = <* FATAL Thread . Alerted , Wr . Failure *> BEGIN Wr . PutText ( GWr , Tag ) ; Wr . PutText ( GWr , Fmt . Int ( J ) ) ; Wr . PutText ( GWr , Wr . EOL ) END WLI ; TYPE Byte = [ - 128 .. 127 ] ; TYPE Arr16 = ARRAY BOOLEAN OF BITS 8 FOR Byte ; TYPE Outer = RECORD Pad : BITS 6 FOR [ 0 .. 63 ] := 0 ; Unaligned : BITS 16 FOR Arr16 END ; PROCEDURE P ( VALUE F : Arr16 ) = VAR I : INTEGER ; BEGIN WLI ( "F[FALSE] = " , F [ FALSE ] ) ; WLI ( "F[TRUE] = " , F [ TRUE ] ) ; I := 10 END P ; PROCEDURE Do ( ) = VAR VOuter := Outer { 57 , Arr16 { 109 , 82 } } ; BEGIN P ( VOuter . Unaligned ) ; WLI ( "VOuter.Pad = " , VOuter . Pad ) ; WLI ( "VOuter.Unaligned[FALSE] = " , VOuter . Unaligned [ FALSE ] ) ; WLI ( "VOuter.Unaligned[TRUE] = " , VOuter . Unaligned [ TRUE ] ) END Do ; BEGIN GWr := Stdio . stdout ; Do ( ) END Main . ------------------------------------------------------------------------------------ Expected output: F[FALSE] = 109 F[TRUE] = 82 VOuter.Pad = 57 VOuter.Unaligned[FALSE] = 109 VOuter.Unaligned[TRUE] = 82 ------------------------------------------------------------------------------------ On 11/21/2017 04:35 PM, GitHub wrote: > Branch: refs/heads/master > Home: https://github.com/modula3/cm3 > Commit: f771611139da4f195e1ce02d894c4dbcf9eab33c > https://github.com/modula3/cm3/commit/f771611139da4f195e1ce02d894c4dbcf9eab33c > Author: Rodney Bates > Date: 2017-11-21 (Tue, 21 Nov 2017) > > Changed paths: > M m3-sys/m3front/src/misc/CG.i3 > M m3-sys/m3front/src/misc/CG.m3 > M m3-sys/m3front/src/values/Formal.m3 > > Log Message: > ----------- > Fix CG internal error, when passing bitpacked array by value. > > -- Rodney Bates rodney.m.bates at acm.org