From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 859 invoked by alias); 1 May 2003 23:50:20 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 852 invoked from network); 1 May 2003 23:50:19 -0000 Received: from unknown (HELO gash2.peakpeak.com) (207.174.178.17) by sources.redhat.com with SMTP; 1 May 2003 23:50:19 -0000 Received: from fleche.redhat.com (tf0199.peakpeak.com [204.144.239.199]) by gash2.peakpeak.com (8.9.3/8.9.3.1) with ESMTP id RAA26418; Thu, 1 May 2003 17:50:16 -0600 Received: by fleche.redhat.com (Postfix, from userid 1000) id 690EE4F80CC; Thu, 1 May 2003 17:42:45 -0600 (MDT) To: Andrew Haley Cc: Jason Merrill , Gabriel Dos Reis , Jamie Lokier , gcc@gcc.gnu.org Subject: Re: On alignment References: <200303251122.13693.kevin.hendricks@sympatico.ca> <200303251344.59988.kevin.hendricks@sympatico.ca> <16037.6826.35777.756256@cuddles.redhat.com> <20030423124944.GA24593@mail.jlokier.co.uk> <87wuhlgq5l.fsf@fleche.redhat.com> <87lly1f5ir.fsf@fleche.redhat.com> <87sms9dmuy.fsf@fleche.redhat.com> <16039.44856.826662.680167@cuddles.redhat.com> From: Tom Tromey Reply-To: tromey@redhat.com X-Attribution: Tom X-Zippy: HAIR TONICS, please!! Date: Thu, 01 May 2003 23:50:00 -0000 In-Reply-To: <16039.44856.826662.680167@cuddles.redhat.com> Message-ID: <87znm6utca.fsf@fleche.redhat.com> User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2003-05/txt/msg00091.txt.bz2 >>>>> "Andrew" == Andrew Haley writes: Jason> A similar trick using offsetof should work with all versions of Jason> gcc; just add a char field to the beginning of the struct, and Jason> measure the offset to the TYPE field. Andrew> Ah, okay. That sounds pretty neat. Andrew> Tom, time for the third (or is it fourth) version of your patch. :-) How will this work? We can't do this: template struct aligner { char dummy; T field; } A plain offsetof(aligner, field) will yield the wrong answer (2 instead of 1). I guess one answer would be "don't bother with byte or boolean". What will eventually go wrong with what we have now? template struct aligner { T field; }; #define ALIGNOF(TYPE) (__alignof__ (((aligner *) 0)->field)) Tom