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: "rguenther at suse dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 20 Dec 2011 11:23:48 +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
--- Comment #8 from rguenther at suse dot de <rguenther at suse dot de> 2011-12-20 11:23:48 UTC ---
On Tue, 20 Dec 2011, ebotcazou at gcc dot gnu.org wrote:
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51628
>
> --- Comment #7 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2011-12-20 11:18:24 UTC ---
> > Huh, it's not. It's the same as a packed struct or enum type.
>
> No, it isn't, the mode is integral instead of BLKmode. In Ada we do support
> misaligned integers, but we simply wrap them in a BLKmode record.
>
> > Why can't you strict-align people simply fix this case?
>
> Because integral modes are naturally aligned. The only reasonable way to
> support the aforementioned abomination is to use the Ada approach.
You mean that handling the TYPE_ALIGN != MODE_ALIGN case when
expanding a MEM_REF (thus, INDIRECT_REF on old branches) won't work?
Why not? You'd simply have to emit the same RTL as when expanding
that wrapped struct case.
Richard.