From owner-cvs-all Thu May 30 2:38:11 2002 Delivered-To: cvs-all@freebsd.org Received: from chiark.greenend.org.uk (chiark.greenend.org.uk [212.135.138.206]) by hub.freebsd.org (Postfix) with ESMTP id B5A4537B406; Thu, 30 May 2002 02:38:04 -0700 (PDT) Received: from fanf by chiark.greenend.org.uk with local (Exim 3.12 #1) id 17DMNf-0006f7-00 (Debian); Thu, 30 May 2002 10:38:03 +0100 Date: Thu, 30 May 2002 10:38:03 +0100 From: Tony Finch To: Marcel Moolenaar Cc: cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/sys gpt.h Message-ID: <20020530103803.D10098@chiark.greenend.org.uk> References: <200205300544.g4U5iN586002@freefall.freebsd.org> <20020530094039.B10098@chiark.greenend.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20020530094039.B10098@chiark.greenend.org.uk>; from dot@dotat.at on Thu, May 30, 2002 at 09:40:39AM +0100 Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, May 30, 2002 at 09:40:39AM +0100, Tony Finch wrote: > On Wed, May 29, 2002 at 10:44:23PM -0700, Marcel Moolenaar wrote: > > > > o Remove GCC specific attribute packed. > > o Add incomplete array padding. > > Note that the padding array you have added doesn't cover the padding in > the struct that you are having trouble with: offsetof(struct gpt_hdr, > padding) == sizeof(struct gpt_hdr), i.e. there are 4 bytes of padding > before the incomplete array member. It's also a gratuitous C99ism -- > a comment would be better. Actually, since you wouldn't have committed this without it getting the results you expected, I've done some more research and it looks like this is a C99 feature that gcc mis-implements, so you are depending on a gcc bug. fanf@ref5.freebsd.org:/d/home/fanf : 0 ; cat test.c #include #include #include struct foo { int32_t a; int16_t b; char pad[]; } foo; int main(void) { printf("sizeof(struct foo) = %u\n", sizeof(struct foo)); printf("offsetof(struct foo, pad) = %u\n", offsetof(struct foo, pad)); return(0); } fanf@ref5.freebsd.org:/d/home/fanf : 0 ; gcc $FANFCFLAGS test.c test.c:8: warning: ISO C89 does not support flexible array members fanf@ref5.freebsd.org:/d/home/fanf : 0 ; ./a.out sizeof(struct foo) = 8 offsetof(struct foo, pad) = 6 fanf@ref5.freebsd.org:/d/home/fanf : 0 ; (gcc's implementation of inline is wrong, too) Tony. -- f.a.n.finch http://dotat.at/ WIGHT PORTLAND PLYMOUTH: SOUTHWEST VEERING WEST 3 OR 4, OCCASIONALLY 5 AT FIRST. MAINLY FAIR. GOOD. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message