🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #171

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

#171
From: Christopher R Volpe
Date: Fri, 31 Jul 1992 01:09
66 lines
3000 bytes
In article <7022@skye.ed.ac.uk>, richard@aiai.ed.ac.uk (Richard Tobin) writes:
|> In article <Bs5pMJ.3nM@twwells.com> bill@twwells.com (T. William Wells) writes:
|> >: 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));
|> 
|> *If* the standard allows "unnecessary" padding, this program is not
|> strictly conforming.
|> 
|> (1.7 Compliance)
|> 
|> "A strictly conforming program ... shall not produce output dependent
|> on any unspecified, undefined, or implementation-defined behavior"

Your reasoning is wrong because your argument is circular. When you say,

   "*IF* the standard ..."

above, you mean to say, 

  "*If* the `as-if' rule can be applied here to allow unnecessary padding, 
  thereby overriding a literal interpretation which clearly states that 
  unnecessary padding is not allowed, THEN the program is not strictly 
  conforming." 

Look at the reasoning here (PRO advocates unnecessary padding):

PRO: "I think unneccessary padding is perfectly ok."
CON: "Wrong. The Standard clearly says padding can only be done for alignment
      purposes."
PRO: "Oh yeah, well that's a *literal* interpretation, but the `as-if' 
      rule states that unnecessary padding is acceptable as long as a 
      strictly conforming program can't tell that it's being done. Can
      you produce such a program? I bet you can't!"
CON: "Oh yeah? Here's one! It prints different output if the compiler
      is inserting unnecessary padding!!!"
PRO: "But *if* unnecessary padding is ok, *then* the program isn't
      Strictly Conforming, *therefore* the as-if rule still applies, 
      *therefore* unnecessary padding is ok!"

PRO's last argument is equivalent to "If A then A". However, you certainly
can't conclude A from that. The following statement is 100% true:

  "If the moon is made of green cheese, then the moon is made of 
   green cheese."

Perfectly true statement. Does that mean the moon is made of green cheese?


|> 
|> -- Richard
|> -- 
|> Richard Tobin,
|> AI Applications Institute,                                R.Tobin@ed.ac.uk
|> Edinburgh University.

-Chris

-- 
==================
Chris Volpe
G.E. Corporate R&D
volpecr@crd.ge.com
Technical Details
Message-ID: <1992Jul31.010941.7282@crd.ge.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!crdgw1!rdsunx.crd.ge.com!bart!volpe
References: <1992Jul28.063356.28005@sq.sq.com> <14216@ksr.com> <Bs5pMJ.3nM@twwells.com> <7022@skye.ed.ac.uk>

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: <1992Jul31.010941.7282@crd.ge.com>
Date: 31 Jul 92 01:09:41 GMT
References: <1992Jul28.063356.28005@sq.sq.com> <14216@ksr.com> <Bs5pMJ.3nM@twwells.com> <7022@skye.ed.ac.uk>
Sender: volpe@bart (Christopher R Volpe)
Reply-To: volpe@ausable.crd.ge.com
Organization: GE Corporate Research & Development
Lines: 66
Nntp-Posting-Host: bart.crd.ge.com