🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #79

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

#79
From: Christopher R Volpe
Date: Mon, 03 Aug 1992 01:10
32 lines
2012 bytes
In article <14330@ksr.com>, jfw@ksr.com (John F. Woods) writes:
|> 
|> >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.

Huh? The Standard and everything in it (e.g. definition of printf, offsetof, 
sizeof, int; and the statement about padding) together defines what that 
program must output, and by a literal interpretation, that program is SC.

|> 
|> 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."

Oh! Well, that's a horse of a different color! Certainly, an interpretation
ruling that favored the Rationale's statement would override a literal
interpretation of the Standard. But I think such a ruling would be necessary.
It doesn't follow from "as-if".

-Chris
-- 
==================
Chris Volpe
G.E. Corporate R&D
volpecr@crd.ge.com
Technical Details
Message-ID: <1992Aug3.011041.1691@crd.ge.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!crdgw1!rdsunx.crd.ge.com!bart!volpe
References: <1992Jul27.183622.794@taumet.com> <1992Jul28.063356.28005@sq.sq.com> <14216@ksr.com> <Bs5pMJ.3nM@twwells.com> <14330@ksr.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!crdgw1!rdsunx.crd.ge.com!bart!volpe
From: volpe@bart.NoSubdomain.NoDomain (Christopher R Volpe)
Newsgroups: comp.std.c
Subject: Re: Character arrays in structures and address alignment -- any standard?
Message-ID: <1992Aug3.011041.1691@crd.ge.com>
Date: 3 Aug 92 01:10:41 GMT
References: <1992Jul27.183622.794@taumet.com> <1992Jul28.063356.28005@sq.sq.com> <14216@ksr.com> <Bs5pMJ.3nM@twwells.com> <14330@ksr.com>
Sender: volpe@bart (Christopher R Volpe)
Reply-To: volpe@ausable.crd.ge.com
Organization: GE Corporate Research & Development
Lines: 32
Nntp-Posting-Host: bart.crd.ge.com