From owner-cvs-all Wed May 29 13:23:13 2002 Delivered-To: cvs-all@freebsd.org Received: from critter.freebsd.dk (critter.freebsd.dk [212.242.86.163]) by hub.freebsd.org (Postfix) with ESMTP id 1417837B411; Wed, 29 May 2002 13:22:36 -0700 (PDT) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.12.3/8.12.2) with ESMTP id g4TKLPKu012032; Wed, 29 May 2002 22:21:25 +0200 (CEST) (envelope-from phk@critter.freebsd.dk) To: Marcel Moolenaar Cc: Tony Finch , cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/sys gpt.h In-Reply-To: Your message of "Wed, 29 May 2002 13:19:27 PDT." <20020529131927.C64995@kayak.xcllnt.net> Date: Wed, 29 May 2002 22:21:25 +0200 Message-ID: <12031.1022703685@critter.freebsd.dk> From: Poul-Henning Kamp 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 In message <20020529131927.C64995@kayak.xcllnt.net>, Marcel Moolenaar writes: >On Wed, May 29, 2002 at 05:36:21PM +0100, Tony Finch wrote: >> On Tue, May 28, 2002 at 10:36:53PM -0700, Marcel Moolenaar wrote: >> > >> > I see what you mean, but packing and unpacking is not the problem. It's >> > sizeof() that's got it wrong. I don't quite understand why sizeof() >> > would yield a size that's 4 bytes longer than the structure actually >> > is. It smells like a gcc bug, but I assume for now I'm just missing >> > something. >> >> It's required for correct alignment of the uint64_t members when you >> create an array of the struct. > >I think it's a mistake to make the padding between elements in an >array part of the type of element. An int32_t followed by an int64_t >in a struct also doesn't cause the int32_t to have a 64-bit size >to handle the alignment of the int64_t that follows it. It's now >totally impossible to answer trivial questions like: > > what's the size of struct X { int64_t a; int32_t b; }; Welcome to "modern C" :-( -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message