From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2646 invoked by alias); 4 Aug 2010 15:33:52 -0000 Received: (qmail 2631 invoked by uid 22791); 4 Aug 2010 15:33:51 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM X-Spam-Check-By: sourceware.org Received: from mail-fx0-f47.google.com (HELO mail-fx0-f47.google.com) (209.85.161.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 04 Aug 2010 15:33:45 +0000 Received: by fxm12 with SMTP id 12so2802023fxm.20 for ; Wed, 04 Aug 2010 08:33:43 -0700 (PDT) Received: by 10.223.122.147 with SMTP id l19mr9095625far.83.1280936022899; Wed, 04 Aug 2010 08:33:42 -0700 (PDT) Received: from [172.16.118.31] ([152.96.0.2]) by mx.google.com with ESMTPS id b11sm3032123faq.6.2010.08.04.08.33.42 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 04 Aug 2010 08:33:42 -0700 (PDT) Message-ID: <4C598855.6020509@gmail.com> Date: Wed, 04 Aug 2010 15:33:00 -0000 From: Martin Sebor User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100301 Fedora/3.0.3-1.fc11 Thunderbird/3.0.3 MIME-Version: 1.0 To: Ulrich Weigand CC: Paul Brook , gcc-patches@gcc.gnu.org, Richard Guenther , Steven Bosscher , dnovillo@google.com, froydnj@codesourcery.com, Mark Mitchell Subject: Re: [PATCH] [4.5 regression] C++ ignores some aligned attributes References: <201008041419.o74EJAXY011360@d12av02.megacenter.de.ibm.com> In-Reply-To: <201008041419.o74EJAXY011360@d12av02.megacenter.de.ibm.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2010-08/txt/msg00312.txt.bz2 On 08/04/2010 08:19 AM, Ulrich Weigand wrote: > 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.) In C++ 0x, the (presumably equivalent) alignof operator had better yield the same result across all translation units to preserve the ODR. Consider: struct S { static int i; }; template struct X { }; template <> struct X { enum { e }; }; int S::i [[align(sizeof (int) * 2)]]; int main() { return X::e; } Martin > > Bye, > Ulrich >