discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: c/10360: __alignof__(double) answer 8


From: Richard Frith-Macdonald
Subject: Re: c/10360: __alignof__(double) answer 8
Date: Thu, 10 Apr 2003 06:06:44 +0100


On Wednesday, April 9, 2003, at 11:40  pm, Richard Henderson wrote:

On Wed, Apr 09, 2003 at 11:59:58PM +0200, Frederic De Jaeger wrote:
Thus, why gcc does not align fields with respect to this *preferred*
alignment?

Because the ABI says not to.

It would be interesting to know in what sense the alignment is 'preferred'.
Surely if the 'ABI says not to' then the alignment is not preferred?

... and we expect it to return the alignment used by the compiler (and not
the *preferred* alignment).

A meaningless number.  Because "the alignment used by the compiler"
is going to depend on the context in which it is used.

I think that Frederic means the alignment the compiler uses to lay out
structures in memory.

It's hard to see how that can be context sensistive since the compiler
needs to know it to access the structure elements via a pointer, so
the code that stored the structure in memory and the code that
retrieves it through the pointer have to use the same alignments.

I imagine this is *by far* the most common context in which anyone
would want to know a type alignment (actually it's the only one I can
think of off hand).

So if __alignof__ is not returning the alignment of a type for structure
layout, how can it be returning the 'preferred' alignment. Shouldn't this
either be fixed as Frederic suggests, or the documentation be changed
so that instead of saying 'preferred' it says 'misleading and largely
useless'

Sorry if this sounds overly aggressive, but I do think that compiler extensions
should be useful and behave as expected, and this behavior seems to
mean that __alignof__ fails in this.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]