public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Martin Sebor <msebor@gmail.com>
To: Ulrich Weigand <uweigand@de.ibm.com>
Cc: Paul Brook <paul@codesourcery.com>,
	gcc-patches@gcc.gnu.org,
	 Richard Guenther <richard.guenther@gmail.com>,
	Steven Bosscher <stevenb.gcc@gmail.com>,
	dnovillo@google.com,  froydnj@codesourcery.com,
	Mark Mitchell <mark@codesourcery.com>
Subject: Re: [PATCH] [4.5 regression] C++ ignores some aligned attributes
Date: Wed, 04 Aug 2010 15:33:00 -0000	[thread overview]
Message-ID: <4C598855.6020509@gmail.com> (raw)
In-Reply-To: <201008041419.o74EJAXY011360@d12av02.megacenter.de.ibm.com>

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 <int> struct X { };
template <> struct X<alignof S::i> { enum { e }; };

int S::i [[align(sizeof (int) * 2)]];

int main() {
     return X<alignof S::i>::e;
}

Martin

>
> Bye,
> Ulrich
>

  parent reply	other threads:[~2010-08-04 15:33 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-08 15:32 [PATCH] fix arm neon ICE by widening tree_type's precision field Nathan Froyd
2009-06-08 17:11 ` Richard Guenther
2009-06-08 18:04 ` Paolo Bonzini
2009-06-08 20:28   ` Nathan Froyd
2009-06-08 20:32     ` Steven Bosscher
2009-06-09  6:36     ` Paolo Bonzini
2009-06-09 14:54       ` Nathan Froyd
2009-06-09 15:00         ` Richard Guenther
2009-06-09 15:07           ` Richard Guenther
2009-06-09 15:44           ` Steven Bosscher
2009-06-10  2:50           ` Eric Botcazou
2009-06-09 15:40         ` Steven Bosscher
2009-06-09 15:53           ` Richard Guenther
2009-06-09 16:31             ` Nathan Froyd
2009-06-09 16:34               ` Richard Guenther
2009-06-09 16:36               ` Diego Novillo
2009-06-09 17:30               ` Paolo Bonzini
2010-07-28 19:01               ` [4.5 regression] C++ ignores some aligned attributes (Re: [PATCH] fix arm neon ICE by widening tree_type's precision field) Ulrich Weigand
2010-07-28 19:40                 ` Richard Guenther
2010-07-29 12:29                   ` [4.5 regression] C++ ignores some aligned attributes (Re: [PATCH] fix arm neon ICE by widening tree_type's precision field Ulrich Weigand
2010-07-28 22:07                 ` [PATCH] [4.5 regression] C++ ignores some aligned attributes Ulrich Weigand
2010-07-30 16:00                   ` Ulrich Weigand
2010-07-30 16:22                     ` Richard Guenther
2010-07-30 16:22                       ` Ulrich Weigand
2010-07-31 17:45                   ` Eric Botcazou
2010-07-31 19:38                     ` Ulrich Weigand
2010-08-04 14:03                   ` Paul Brook
2010-08-04 14:19                     ` Ulrich Weigand
2010-08-04 14:27                       ` Mark Mitchell
2010-08-04 15:04                       ` Paul Brook
2010-08-04 16:42                         ` Ulrich Weigand
2010-08-04 15:33                       ` Martin Sebor [this message]
2010-08-04 15:47                         ` Mark Mitchell
2010-08-05  9:02                           ` Martin Sebor
2009-06-08 19:40 ` [PATCH] fix arm neon ICE by widening tree_type's precision field Joseph S. Myers
2009-06-08 19:52   ` Daniel Jacobowitz
2009-06-08 20:12     ` Andrew Pinski
2009-06-08 20:20     ` Jakub Jelinek
2009-06-08 20:33       ` Daniel Jacobowitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C598855.6020509@gmail.com \
    --to=msebor@gmail.com \
    --cc=dnovillo@google.com \
    --cc=froydnj@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=mark@codesourcery.com \
    --cc=paul@codesourcery.com \
    --cc=richard.guenther@gmail.com \
    --cc=stevenb.gcc@gmail.com \
    --cc=uweigand@de.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).