Array bounds checking with C????
Chris Torek
chris at mimsy.umd.edu
Mon Aug 27 20:39:09 AEST 1990
In article <26196 at mimsy.umd.edu> I wrote:
>>... it still objected to `&arr[sizeof arr/sizeof *arr]',
>>which is Officially Legal.
In article <619.26d6cfb2 at iccgcc.decnet.ab.co> browns at iccgcc.decnet.ab.com
(Stan Brown, Oak Road Systems) writes:
>Just to stick in my $.02:
>
>int arr[4];
>
>sizeof arr/sizeof *arr is 4, so &arr[4] may not be legal. Whether legal or
>not, the address is certainly outside the array.
See ANSI standard X3.159-1989, section 3.3.6, `additive operators'.
(I might have included this before but I was at home.) As I said, it
is Officially Legal.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 405 2750)
Domain: chris at cs.umd.edu Path: uunet!mimsy!chris
More information about the Comp.lang.c
mailing list