From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1665 invoked by alias); 23 Apr 2003 12:49:46 -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 1652 invoked from network); 23 Apr 2003 12:49:45 -0000 Received: from unknown (HELO mail.jlokier.co.uk) (81.29.64.88) by sources.redhat.com with SMTP; 23 Apr 2003 12:49:45 -0000 Received: from mail.jlokier.co.uk (localhost [127.0.0.1]) by mail.jlokier.co.uk (8.12.8/8.12.8) with ESMTP id h3NCnijF024620; Wed, 23 Apr 2003 13:49:45 +0100 Received: (from jamie@localhost) by mail.jlokier.co.uk (8.12.8/8.12.8/Submit) id h3NCniau024618; Wed, 23 Apr 2003 13:49:44 +0100 Date: Wed, 23 Apr 2003 13:32:00 -0000 From: Jamie Lokier To: Andreas Schwab Cc: Andrew Haley , Jason Merrill , gcc@gcc.gnu.org Subject: Re: On alignment Message-ID: <20030423124944.GA24593@mail.jlokier.co.uk> References: <200303251122.13693.kevin.hendricks@sympatico.ca> <200303251344.59988.kevin.hendricks@sympatico.ca> <16037.6826.35777.756256@cuddles.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.1i X-SW-Source: 2003-04/txt/msg01147.txt.bz2 Andreas Schwab wrote: > Andrew Haley writes: > |> WHat I still cannot understand is why a struct that contains a double > |> is 4-aligned on x86, but a double is 8-aligned. This means that you > |> cannot infer the alignment of a struct from the alignment of its > |> members. Is this really part of the multi-vendor ABI? > > The alignment of a struct member determines the amount of padding that > must be inserted, thus it is important to maintain the exact alignment > requirements of the ABI. For simple variables there is no such > requirement, there is never a problem when a standalone variable is > overaligned. For the same reason, "struct foo { double x; }" as a standalone variable should have alignment 8, not 4. Andrew's test shows it has an alignment of 4. Exactly like "double", "struct foo" should have size and alignment 8, but when it's a field in a larger structure it should pack with alignment 4. -- Jamie