From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C608A384AB58; Thu, 2 May 2024 22:52:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C608A384AB58 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1714690321; bh=cGy/3GWDq3tgR7a5XoelFwo+R5cpW7zSYCp0riCgLc0=; h=From:To:Subject:Date:From; b=Zv0WvycyPv1MrheFrnDYLN2YMutyTpCM8xT7pPqvvhswMFhVWlsKoTdbYCkp72Dws ncWJBRK5YEJ/+FrDb8NJFHwMRuMRxLOzsaOSNrw9Ff78DnJH+MewUbnvzqaHxuc9rD wcXkR2B2ZyGYF6Hd/GVdw9fGUfR0d9H0kvfvK/3c= From: "dhylands at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/114928] New: #pragma packed(push,1) should give the same warning as __attribute__((packed)) Date: Thu, 02 May 2024 22:52:00 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dhylands at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned 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 attachments.created 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=3D114928 Bug ID: 114928 Summary: #pragma packed(push,1) should give the same warning as __attribute__((packed)) Product: gcc Version: 13.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: dhylands at gmail dot com Target Milestone: --- Created attachment 58091 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D58091&action=3Dedit File that compiles with no warnings I'm using the ARM Toolchain arm-gnu-toolchain-13.2.Rel1-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-= linux-gnu-g++ running on Ubuntu 20.04 If I delcare my structure using: struct Foo { char y; int x; } __attribute__((packed)); then the compiler correctly gives me a warning about taking the address of a packed member: warning: taking address of packed member of =E2=80=98Foo=E2=80=99 may resul= t in an unaligned pointer value [-Waddress-of-packed-member] However, if I change the structure to use #pragma pack(push, 1)=20 #pragma pack(push, 1) struct Foo { char y; int x; }; #pragma pack(pop) then I don't get the warning (and my bug is that it should give the same warning). In either case the member offsets and structure size are the same.=