From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29943 invoked by alias); 21 Apr 2003 21:35:52 -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 29931 invoked from network); 21 Apr 2003 21:35:52 -0000 Received: from unknown (HELO nile.gnat.com) (205.232.38.5) by sources.redhat.com with SMTP; 21 Apr 2003 21:35:52 -0000 Received: by nile.gnat.com (Postfix, from userid 338) id 97122F28D2; Mon, 21 Apr 2003 17:35:51 -0400 (EDT) To: aoliva@redhat.com, dewar@gnat.com Subject: Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT Cc: gcc-patches@gcc.gnu.org, gcc@gcc.gnu.org, kenner@vlsi1.ultra.nyu.edu, rth@redhat.com Message-Id: <20030421213551.97122F28D2@nile.gnat.com> Date: Tue, 22 Apr 2003 00:11:00 -0000 From: dewar@gnat.com (Robert Dewar) X-SW-Source: 2003-04/txt/msg01019.txt.bz2 > So if you turn: > > T i __attribute__((align(2))); > T j __attribute__((align(2))); > > into > > typedef T T2 __attribute__((align(2))); > T2 i, j; > > you say we could get different code? It sounds to me like they > *should* be equivalent. The compiler can't tell whether the user > meant the alignment of a type is meant for composites only or for > factoring of attributes in object declarations. Yes, at least that's the intention in Ada. Setting an alignment for a type specifies a minimum alignment for objects. Consider the following type A is .... for A'Alignment use 4; B : A: Put_Line (Integer'Image (B'Alignment)); Ada semantics say that the value printed must be 4 or a multiple of 4. type A is ... B : A; for B'Alignment use 4; Put_Line (Integer'Image (B'Alignment)); This must output 4. Of course the compiler could still silently put B on a bigger alignment, since there would be no way to tell that it was doing this systematically, but this would be a poor implementation.