This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]