From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7EC2D3858D39; Tue, 3 Oct 2023 10:35:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7EC2D3858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1696329326; bh=AKoHNVHTx8en746RWj+mi/0zJDfj0beflIh91+orvno=; h=From:To:Subject:Date:From; b=vO1Fbro8qBEZh2QGHWP2s4VilNrZ72NaWIUZb8fZeD7ckDOTGX8AS6Tp7ujXmAOUJ BdjWj9ibgoxZJha5s60cT9juirh3uTL1+SwROz2RvFqvKH9QsJtQ+pJk139Rbdnb1w um9/Tlv1sm6xG7h1f+mH9Koz4avDBH6ihwyabn3I= From: "gaius at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug modula2/111675] New: Incorrect parameter value passed when attempting to pass a field of a packed record as a parameter Date: Tue, 03 Oct 2023 10:35:25 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: modula2 X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: gaius at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: gaius at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D111675 Bug ID: 111675 Summary: Incorrect parameter value passed when attempting to pass a field of a packed record as a parameter Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: modula2 Assignee: gaius at gcc dot gnu.org Reporter: gaius at gcc dot gnu.org Target Milestone: --- Summary cannot pass a packed field by value to a procedure as it results in= a garbled value. Consider the example below, if compiled and run we get: $ gm2 -g packedrecord3.mod $ ./a.out failed to pass 0 into test $ gdb ./a.out (gdb) break printf (gdb) run Breakpoint 3, __printf (format=3D0x402008 "failed to pass %d into test\n")= =20 (gdb) where #0 __printf (format=3D0x402008 "failed to pass %d into test\n") at printf.= c:28 #1 0x0000000000401387 in test (s=3D36893488147419103232, level=3D0) at packedrecord3.mod:25 #2 0x00000000004012ce in _M2_packedrecord3_init (argc=3D1, argv=3D0x7fffff= ffe448, envp=3D0x7fffffffe458) at packedrecord3.mod:47 oddly print sizeof s gives 16 !=20=20 module packedrecord3 ; (*!m2iso+gm2*) from libc import printf, exit ; type subrange =3D [0..63] ; packedrec =3D record <* bytealignment (0) *> bool: boolean ; col : (white, black) ; sub : subrange ; end ; var global: subrange ; pr : packedrec ; procedure test (s: subrange; level: cardinal) ; begin if s # global then printf ("failed to pass %d into test\n", ord (s)) ; exit (1) end ; if level > 0 then test (s, level-1) end end test ; begin if size (pr) # 1 then printf ("test failed as size (pr) should be 1 not %d\n", size (pr)) ; exit (1) end ; for global :=3D min (subrange) to max (subrange) do test (global, 2) end ; for global :=3D min (subrange) to max (subrange) do pr.bool :=3D false ; pr.sub :=3D global ; test (pr.sub, 2) end end packedrecord3.=