Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 28 Apr 2014 10:14:20 -0400
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: [PATCH 3/3] stddef: Define max_align_t

On Mon, Apr 28, 2014 at 03:26:45PM +0200, Szabolcs Nagy wrote:
> * Jens Gustedt <jens.gustedt@...ia.fr> [2014-04-28 14:22:44 +0200]:
> > Am Montag, den 28.04.2014, 12:11 +0200 schrieb Szabolcs Nagy:
> > > i think i386 abi is non-conforming to the c11 alignment requirements now:
> > > long long has 8 byte alignment, but in a struct/union it has only 4
> > > (this is why the attrs are needed above)
> > > 
> > > 	long long x; // _Alignof(x) == 8
> > > 	struct {long long x;} y; // _Alignof(y.x) == 4
> > 
> > I don't think that it is non-conforming
> > 
> > _Alignof of a type only tells you on what alignments the programmer
> > may place objects of the corresponding type (if he deals with this
> > manually) and gives no guarantee what the implementation itself choses
> > under all circumstances
> > 
> > this holds especially if a type has "extended alignment", I think
> 
> the standard says
> 
> "An object type imposes an alignment requirement on every object of that
> type: stricter alignment can be requested using the _Alignas keyword."
> 
> "The _Alignof operator yields the alignment requirement of its operand type."
> 
> to me this means that all long long objects should have the same
> alignment requirement and _Alignof should return this consistently
> (unless _Alignas imposes further stricter alignment requirements,
> but it never gets weaker)

This is correct. On i386, _Alignof must both always be 4 for both long
long and long double, regardless of where the operand (if it's an
object rather than a type) exists. If gcc is behaving differently,
this is a very bad bug in GCC that needs to be fixed on their side; I
won't try to work around it.

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.