From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14743 invoked by alias); 10 Apr 2003 05:16:00 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 14729 invoked by uid 71); 10 Apr 2003 05:16:00 -0000 Date: Thu, 10 Apr 2003 05:16:00 -0000 Message-ID: <20030410051600.14728.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Richard Frith-Macdonald Subject: Re: c/10360: __alignof__(double) answer 8 Reply-To: Richard Frith-Macdonald X-SW-Source: 2003-04/txt/msg00415.txt.bz2 List-Id: The following reply was made to PR c/10360; it has been noted by GNATS. From: Richard Frith-Macdonald To: Richard Henderson Cc: gcc-gnats@gcc.gnu.org, thoran@free.fr, nobody@gcc.gnu.org, gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org, discuss-gnustep@gnu.org, rth@gcc.gnu.org, Frederic De Jaeger 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.