home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / std / c / 2585 < prev    next >
Encoding:
Internet Message Format  |  1992-09-08  |  2.0 KB

  1. Path: sparky!uunet!mcsun!uknet!acorn!ixi!clive
  2. From: clive@x.co.uk (Clive Feather)
  3. Newsgroups: comp.std.c
  4. Subject: Re: struct hack, was Re: strcpy implementation question
  5. Message-ID: <1992Sep07.104932.20060@x.co.uk>
  6. Date: 7 Sep 92 10:49:32 GMT
  7. References: <9209040741.AA16120@enet-gw.pa.dec.com>
  8. Organization: IXI Limited, Cambridge, UK
  9. Lines: 28
  10.  
  11. In article <9209040741.AA16120@enet-gw.pa.dec.com> diamond@jit081.enet.dec.com (04-Sep-1992 1639) writes:
  12. >In article <1992Sep4.015335.3612@thinkage.on.ca> dat@thinkage.on.ca (David Adrien Tanguay) writes:
  13. >>diamond@jit081.enet.dec.com (03-Sep-1992 1325) writes:
  14. >>>In article <PINKAS.92Sep2173635@skywalker.intel.com> pinkas@skywalker.intel.com (Israel Pinkas) writes:
  15. >>>> The variable length struct is a hack.  There is nothing in the language that
  16. >>>> prevents the compiler from performing bounds checking on accesses to name.
  17. >>> Bounds checking is not allowed to affect output of a valid but ugly program.
  18. >> I had the impression that the last time it came up here the conclusion was
  19. >> that this trick was not sanctioned[...]  3.3.6 "Additive Operators"
  20. >> says that you aren't guaranteed to go past the end of an array object,
  21. > No (though it was the conclusion of some others) and yes, respectively.
  22. > You can't go past the end of an array object.  But if malloc() or some other
  23. > variable has defined the end of the actual array object, then the + operator
  24. > can get you that far, regardless of the declared type that some other array
  25. > variable had before getting flattened to a pointer.
  26.  
  27. But there is an intepretation that says that, given
  28.  
  29.     int a [5][5];
  30.  
  31. the access "a [1][6]" is illegal, because it goes past the bounds of the
  32. array "a [1]". In other words, the declared type of the array does
  33. restrict what can happen to a pointer derived from it.
  34. -- 
  35. Clive D.W. Feather     | IXI Limited         | If you lie to the compiler,
  36. clive@x.co.uk          | 62-74 Burleigh St.  | it will get its revenge.
  37. Phone: +44 223 462 131 | Cambridge   CB1 1OJ |   - Henry Spencer
  38. Fax:   +44 223 462 132 | United Kingdom      |
  39.