bounds checking (was: X3J11 Pleasanton meeting summary)

Karl Heuer karl at haddock.ima.isc.com
Tue Oct 9 05:18:21 AEST 1990


In article <14049 at smoke.BRL.MIL> gwyn at smoke.BRL.MIL (Doug Gwyn) writes:
>	int a[4][5];
>	a[1][7] = 0;	/* undefined behavior */
>[justification for the above]

I presume that this ruling (if upheld) also means that strictly conforming
programs may not use extensible structs via the usual overmalloc hack?

>What is missing in the standard that would be required for such punning
>to be strictly conforming is some sort of guarantee that an array of
>arrays of T is also in some contexts considered an array of T itself.

I believe X3J11 has previously stated that "objects are composed of bytes"
means that any object may be considered an array of char.  If this continues
to be true, and yet the above example is illegal, then there's a bunch of
intermediate cases that have questionable legality.  I posted an article about
this (my "proof" that extensible structs are legal) on or around 20-Dec-1989,
I think.  Anyone still have a copy?

Karl W. Z. Heuer (karl at kelp.ima.isc.com or ima!kelp!karl), The Walking Lint



More information about the Comp.std.c mailing list