This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/51628] __attribute__((packed)) is unsafe in some cases
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 20 Dec 2011 10:20:19 +0000
- Subject: [Bug c/51628] __attribute__((packed)) is unsafe in some cases
- Auto-submitted: auto-generated
- References: <bug-51628-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51628
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
Status|UNCONFIRMED |NEW
Last reconfirmed| |2011-12-20
CC| |ebotcazou at gcc dot
| |gnu.org, rguenth at gcc dot
| |gnu.org
Ever Confirmed|0 |1
--- Comment #4 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-12-20 10:20:19 UTC ---
The point is that even if you use sth like
typedef int myint __attribute__((aligned(1)));
to capture the misaligned pointer to the packed structure element:
myint *p = &s->i;
then accesses like '*p' will still assume an _aligned_ int at 'p' for
STRICT_ALIGNMENT targets.
That's a long-long-long-standing bug and a cause of major headache for
more modern GCCs even ...
The testcase with using a 'int *' pointer is indeed invalid though.