home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / std / c / 2394 < prev    next >
Encoding:
Internet Message Format  |  1992-07-30  |  2.9 KB

  1. Path: sparky!uunet!crdgw1!rdsunx.crd.ge.com!bart!volpe
  2. From: volpe@bart.NoSubdomain.NoDomain (Christopher R Volpe)
  3. Newsgroups: comp.std.c
  4. Subject: Re: Character arrays in structures and address alignment -- any standard?
  5. Message-ID: <1992Jul31.010941.7282@crd.ge.com>
  6. Date: 31 Jul 92 01:09:41 GMT
  7. References: <1992Jul28.063356.28005@sq.sq.com> <14216@ksr.com> <Bs5pMJ.3nM@twwells.com> <7022@skye.ed.ac.uk>
  8. Sender: volpe@bart (Christopher R Volpe)
  9. Reply-To: volpe@ausable.crd.ge.com
  10. Organization: GE Corporate Research & Development
  11. Lines: 66
  12. Nntp-Posting-Host: bart.crd.ge.com
  13.  
  14. In article <7022@skye.ed.ac.uk>, richard@aiai.ed.ac.uk (Richard Tobin) writes:
  15. |> In article <Bs5pMJ.3nM@twwells.com> bill@twwells.com (T. William Wells) writes:
  16. |> >: Please show a strictly conforming program which can tell the difference
  17. |> >: between "necessary" padding and "unnecessary" padding.
  18. |> 
  19. |> >For example:
  20. |> 
  21. |> >    printf("%d\n", (offsetof(foo, y) - offset(foo, x)) - sizeof(int));
  22. |> 
  23. |> *If* the standard allows "unnecessary" padding, this program is not
  24. |> strictly conforming.
  25. |> 
  26. |> (1.7 Compliance)
  27. |> 
  28. |> "A strictly conforming program ... shall not produce output dependent
  29. |> on any unspecified, undefined, or implementation-defined behavior"
  30.  
  31. Your reasoning is wrong because your argument is circular. When you say,
  32.  
  33.    "*IF* the standard ..."
  34.  
  35. above, you mean to say, 
  36.  
  37.   "*If* the `as-if' rule can be applied here to allow unnecessary padding, 
  38.   thereby overriding a literal interpretation which clearly states that 
  39.   unnecessary padding is not allowed, THEN the program is not strictly 
  40.   conforming." 
  41.  
  42. Look at the reasoning here (PRO advocates unnecessary padding):
  43.  
  44. PRO: "I think unneccessary padding is perfectly ok."
  45. CON: "Wrong. The Standard clearly says padding can only be done for alignment
  46.       purposes."
  47. PRO: "Oh yeah, well that's a *literal* interpretation, but the `as-if' 
  48.       rule states that unnecessary padding is acceptable as long as a 
  49.       strictly conforming program can't tell that it's being done. Can
  50.       you produce such a program? I bet you can't!"
  51. CON: "Oh yeah? Here's one! It prints different output if the compiler
  52.       is inserting unnecessary padding!!!"
  53. PRO: "But *if* unnecessary padding is ok, *then* the program isn't
  54.       Strictly Conforming, *therefore* the as-if rule still applies, 
  55.       *therefore* unnecessary padding is ok!"
  56.  
  57. PRO's last argument is equivalent to "If A then A". However, you certainly
  58. can't conclude A from that. The following statement is 100% true:
  59.  
  60.   "If the moon is made of green cheese, then the moon is made of 
  61.    green cheese."
  62.  
  63. Perfectly true statement. Does that mean the moon is made of green cheese?
  64.  
  65.  
  66. |> 
  67. |> -- Richard
  68. |> -- 
  69. |> Richard Tobin,
  70. |> AI Applications Institute,                                R.Tobin@ed.ac.uk
  71. |> Edinburgh University.
  72.  
  73. -Chris
  74.  
  75. -- 
  76. ==================
  77. Chris Volpe
  78. G.E. Corporate R&D
  79. volpecr@crd.ge.com
  80.