home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / std / c / 3434 < prev    next >
Encoding:
Text File  |  1993-01-28  |  2.7 KB  |  54 lines

  1. Newsgroups: comp.std.c
  2. Path: sparky!uunet!ferkel.ucsb.edu!taco!gatech!swrinde!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!usenet.coe.montana.edu!decwrl!pa.dec.com!engage.pko.dec.com!nntpd.lkg.dec.com!jit345.bad.jit.dec.com!diamond
  3. From: diamond@jit345.bad.jit.dec.com (Norman Diamond)
  4. Subject: Re: Structure walking
  5. Message-ID: <1993Jan27.014643.21507@nntpd.lkg.dec.com>
  6. Sender: usenet@nntpd.lkg.dec.com (USENET News System)
  7. Reply-To: diamond@jit.dec.com (Norman Diamond)
  8. Organization: Digital Equipment Corporation Japan , Tokyo
  9. References: <1993Jan25.213543.25499@pony.Ingres.COM> <565@heimdall.sdrc.com>
  10. Date: Wed, 27 Jan 1993 01:46:43 GMT
  11. Lines: 41
  12.  
  13. In article <565@heimdall.sdrc.com> scjones@thor.sdrc.com (Larry Jones) writes:
  14. >In article <1993Jan25.213543.25499@pony.Ingres.COM>, mikes@Ingres.COM (Mike Schilling) writes:
  15. >> (e) The alignment required by the structure is equal to the most restrictive
  16. >>     alignment of any of its members.
  17.  
  18. >True, but see (a).
  19.  
  20. Well Mr. Jones, you and I seem to be the only people who feel this way.
  21. Most of the regulars in this group felt that even a structure like this:
  22.    struct mychar { char x; }
  23. might be given an alignment requirement of 32 by some compiler, even if
  24. char only requires an alignment of 1 under the same compiler.  Of course,
  25. I only saw this on Usenet; you've seen the committee's deliberations.
  26.  
  27. >> (f) The size of the structure is the offset of the last member of the structure,
  28. >>     plus the size of the last member, rounded up to alignment required
  29. >>     by the structure.
  30.  
  31. >False.  ANSI 3.5.2.1 again:
  32. >    There may also be unnamed padding at the end of a structure or
  33. >    union, as necessary to achieve the *appropriate* alignment were
  34. >    the structure or union to be an element of an array.
  35. >Again, it says "appropriate", not "required".
  36.  
  37. Now I don't understand.  Strictly speaking, the alignment of each member
  38. was already a matter of appropriateness rather than requirement, because
  39. no alignment is really required.  It is always possible to bit-align a
  40. float but do lots of byte moves and integral shifts to move the float into
  41. a temporary location properly aligned for a hardware operation.
  42.  
  43. So, an appropriate alignment for a structure is equal to the most
  44. restrictive appropriate alignment of any of its members, right?
  45. Then, how can the unnamed padding at the end, as NECESSARY to achieve
  46. appropriate alignment were it an array member, be any different from
  47. Mr. Schilling's computation?
  48.  
  49. I think that the answer to (f) cannot differ from the answer to (e).
  50. --
  51. Norman Diamond                diamond@jit.dec.com
  52. If this were the company's opinion, I wouldn't be allowed to post it.
  53. Pardon me?  Or do I have to commit a crime first?
  54.