home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / std / c / 3348 < prev    next >
Encoding:
Text File  |  1993-01-08  |  1.6 KB  |  48 lines

  1. Newsgroups: comp.std.c
  2. Path: sparky!uunet!unislc!ttobler
  3. From: ttobler@unislc.uucp (Trent Tobler)
  4. Subject: Re: Struct hack one last time (one last time)
  5. X-Newsreader: Tin 1.1 PL5
  6. References: <1993Jan8.190840.11087@taumet.com>
  7. Message-ID: <1993Jan8.220422.20084@unislc.uucp>
  8. Organization: Unisys Corporation SLC
  9. Date: Fri, 8 Jan 1993 22:04:22 GMT
  10. Lines: 36
  11.  
  12. Steve Clamage (steve@taumet.com) wrote:
  13. : msb@sq.sq.com (Mark Brader) writes:
  14. : >In particular, it could not modify padding at the end of a struct,
  15. : >precisely *because* it would break the struct hack.
  16. : We seem to have some circular reasoning here.
  17. : I proposed an implemention which I claimed was conforming on which
  18. : the struct hack would not work; therefore the struct hack is illegal.
  19.  
  20.  ...
  21.  
  22. : For example, if the struct hack is strictly conforming, what about this:
  23. :     struct S {
  24. :         double a[2];
  25. :         double b;
  26. :     } s;
  27. :     s.a[2] = 1.0;
  28. : The array reference exceeds the declared bounds of s.a, but not the
  29. : bounds of object s, because sizeof(s) can't be smaller than
  30. : sizeof(a)+sizeof(b).  If a compiler can't add padding to the end of
  31. : the struct for other than alignment, then surely it can't add padding
  32. : between a and b, because it can't be required for alignment.  Therefore
  33. : s.a[2] must be the same as s.b.
  34.  
  35. First off, the compiler is free to add padding for whatever reasons it
  36. wants.. but it must not depend on the value of this padding information.
  37. Second, in your example, a[2] would be equal to 1.0.  It says nothing 
  38. about the value of b.  Because the contents of b may or may not be changed,
  39. it's value is not definite.
  40.  
  41. --
  42.   Trent Tobler
  43.