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