This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] [4.5 regression] C++ ignores some aligned attributes
- From: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: paul at codesourcery dot com (Paul Brook)
- Cc: gcc-patches at gcc dot gnu dot org, richard dot guenther at gmail dot com (Richard Guenther), stevenb dot gcc at gmail dot com (Steven Bosscher), dnovillo at google dot com, froydnj at codesourcery dot com, mark at codesourcery dot com (Mark Mitchell)
- Date: Wed, 4 Aug 2010 16:19:10 +0200 (CEST)
- Subject: Re: [PATCH] [4.5 regression] C++ ignores some aligned attributes
Paul Brook wrote:
> I'm not so sure. Consider the following example:
>
> struct JSString
> {
> unsigned char mLength;
> static JSString unitStringTable[];
> };
>
> int var1 =__alignof__ (JSString::unitStringTable);
>
> JSString JSString::unitStringTable[] __attribute__ ((aligned (8))) = { 1 };
> int var2 =__alignof__ (JSString::unitStringTable);
>
> int main()
> {
> assert(var1 == var2);
> }
>
> Note that var1 may be in a separate file, and never see the additional
> attribute.
>
> Should we be rejecting this mismatch, rather than papering over what looks
> like user error? If the packed attribute can reduce alignment then this is
> going to cause havoc on STRICT_ALIGN targets.
Well, the only thing my patch does is to revert behavior back to what it was
in 4.4 and earlier, after having been (clearly inadvertently) changed by an
unrelated patch. At least Firefox relies on that behavior; Firefox builds
would certainly break if we add the error you suggest ...
That said, I have no strong opinion on what the behavior *should* be in
the case of differing aligned attributes between declaration and definition.
(However, I would suggest to keep the behavior the same between C and C++
whereever that makes sense.)
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com