home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / std / c / 2377 < prev    next >
Encoding:
Internet Message Format  |  1992-07-29  |  2.1 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: <1992Jul29.124005.22841@crd.ge.com>
  6. Date: 29 Jul 92 12:40:05 GMT
  7. References: <1992Jul26.225252.4487@anasazi.com> <1992Jul27.183622.794@taumet.com> <1992Jul28.063356.28005@sq.sq.com> <14216@ksr.com> <bs3x0j.ilr@wang.com> <14235@ksr.com>
  8. Sender: volpe@bart (Christopher R Volpe)
  9. Reply-To: volpe@ausable.crd.ge.com
  10. Organization: GE Corporate Research & Development
  11. Lines: 39
  12. Nntp-Posting-Host: bart.crd.ge.com
  13.  
  14. In article <14235@ksr.com>, jfw@ksr.com (John F. Woods) writes:
  15. |> restriction or requirement is met.  For example, it was claimed at one time
  16. |> that, although the Standard lists two and only two kinds of null pointer
  17. |> constants (an integral constant zero or an integral constant zero cast to
  18. |> void *), a compiler could make NULL expand into (char *)0, because a strictly
  19. |> conforming program couldn't tell the difference.  Doug Gwyn (I think) then
  20. |> demonstrated one that could, taking advantage of the # operator.
  21.  
  22. I believe that was me, not Doug. 
  23.  
  24. |> What the standard says about alignment of things in a structure is:
  25. |> 
  26. |>     "Each non-bit-field member of a structure or union object is aligned
  27. |>     in an implementation-defined manner appropriate to its type."
  28. |> 
  29. |> An implementation must document its strategy, but
  30. |> 
  31. |>     "For all types, structure members are aligned on 16-byte boundaries,
  32. |>     except on Fat Tuesday and Christmas, when for all types, structure
  33. |>     members are aligned on 64-byte boundaries for good luck."
  34.  
  35. I guess we've exhausted all creative examples of undefined behavior, so
  36. we're moving on to implementation-defined behavior :). I love it!
  37.  
  38. |> 
  39. |> is perfectly acceptable, even if everything is addressable on arbitrary byte
  40. |> boundaries.  If you would quibble with whether that is "appropriate", either
  41. |> write a SCP that exposes the error, or chalk it up to "quality of
  42. |> implementation".
  43.  
  44. I would agree with that.
  45.  
  46. -Chris
  47.  
  48. -- 
  49. ==================
  50. Chris Volpe
  51. G.E. Corporate R&D
  52. volpecr@crd.ge.com
  53.