From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22938 invoked by alias); 2 Aug 2005 19:40:49 -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 22911 invoked by uid 22791); 2 Aug 2005 19:40:42 -0000 Received: from host217-40-213-68.in-addr.btopenworld.com (HELO SERRANO.CAM.ARTIMI.COM) (217.40.213.68) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Tue, 02 Aug 2005 19:40:42 +0000 Received: from mace ([192.168.1.25]) by SERRANO.CAM.ARTIMI.COM with Microsoft SMTPSVC(6.0.3790.211); Tue, 2 Aug 2005 20:40:40 +0100 From: "Dave Korn" To: "'Shaun Jackman'" , "'Paul Koning'" Cc: Subject: RE: memcpy to an unaligned address Date: Tue, 02 Aug 2005 19:40:00 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit In-Reply-To: <7f45d9390508021226ea16fc7@mail.gmail.com> Message-ID: X-SW-Source: 2005-08/txt/msg00078.txt.bz2 ----Original Message---- >From: Shaun Jackman >Sent: 02 August 2005 20:26 > On 8/2/05, Paul Koning wrote: >> One of the things that continues to baffle me (and my colleagues) is >> the bizarre way in which attributes such as "packed" work when applied >> to structs. >> >> It would be natural to assume, as Shaun did, that marking a struct >> "packed" (or, for that matter, "packed,aligned(2)") would apply that >> attribute to the fields of the struct. > > This is exactly the behaviour suggested by the info docs: > > $ info gcc 'C Ext' 'Type Attr' > ... > Specifying this attribute for `struct' and `union' types is > equivalent to specifying the `packed' attribute on each of the > structure or union members. > There are two separate issues here: 1) Is the base of the struct aligned to the natural alignment, or can the struct be based at any address 2) Is there padding between the struct members to maintain their natural alignments (on the assumption that the struct's base address is aligned.) I think this is where some of the ambiguity in the docs comes from. But I'm about to leave the office now, so I can't go into depth with this thread right now.... cheers, DaveK -- Can't think of a witty .sigline today....