🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #176

Re: Character arrays in structures and address alignment -- any standard?

#176
From: John F. Woods
Date: Fri, 31 Jul 1992 16:42
23 lines
1623 bytes
bill@twwells.com (T. William Wells) writes:
>In article <14216@ksr.com> jfw@ksr.com (John F. Woods) writes:
>: msb@sq.sq.com (Mark Brader) writes:
>: >> The Standard allows arbitrary padding between fields and after the
>: >> last field.
>: >It does not say anything about padding being permitted
>: >for any other reasons, and my interpretation is that it isn't.
>: Please show a strictly conforming program which can tell the difference
>: between "necessary" padding and "unnecessary" padding.

>For example:
>	printf("%d\n", (offsetof(foo, y) - offset(foo, x)) - sizeof(int));
>should print 0 on any standards conforming compiler, if it is true that the
>standard permits only padding for the purpose of creating proper alignment.

Conversely, in the absense of any means of deriving from the Standard this
unstated requirement, the program is not strictly conforming.

The Rationale isn't the Standard, but I'll quote it anyway: 3.5.2.1 "Since
some existing implementations, in the interest of enhanced access time, leave
internal holes larger than absolutely necessary, it is not clear that a
portable deterministic method can be given for traversing a structure field
by field."
Technical Details
Message-ID: <14330@ksr.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!iWarp.intel.com|eff!world!ksr!jfw
References: <1992Jul27.183622.794@taumet.com> <1992Jul28.063356.28005@sq.sq.com> <14216@ksr.com> <Bs5pMJ.3nM@twwells.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!iWarp.intel.com|eff!world!ksr!jfw
From: jfw@ksr.com (John F. Woods)
Newsgroups: comp.std.c
Subject: Re: Character arrays in structures and address alignment -- any standard?
Message-ID: <14330@ksr.com>
Date: 31 Jul 92 12:42:36 EDT
References: <1992Jul27.183622.794@taumet.com> <1992Jul28.063356.28005@sq.sq.com> <14216@ksr.com> <Bs5pMJ.3nM@twwells.com>
Sender: news@ksr.com
Lines: 23