This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
Re: c/10360: __alignof__(double) answer 8
- From: Richard Frith-Macdonald <richard at brainstorm dot co dot uk>
- To: nobody at gcc dot gnu dot org
- Cc: gcc-prs at gcc dot gnu dot org,
- Date: 10 Apr 2003 05:16:00 -0000
- Subject: Re: c/10360: __alignof__(double) answer 8
- Reply-to: Richard Frith-Macdonald <richard at brainstorm dot co dot uk>
The following reply was made to PR c/10360; it has been noted by GNATS.
From: Richard Frith-Macdonald <richard at brainstorm dot co dot uk>
To: Richard Henderson <rth at redhat dot com>
Cc: gcc-gnats at gcc dot gnu dot org, thoran at free dot fr, nobody at gcc dot gnu dot org,
gcc-prs at gcc dot gnu dot org, gcc-bugs at gcc dot gnu dot org, discuss-gnustep at gnu dot org,
rth at gcc dot gnu dot org, Frederic De Jaeger <dejaeger at free dot fr>
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.