PATCH: BPs & cleanups for ARRAY_SIZE

Greg McGary
Wed Aug 23 16:11:00 GMT 2000

Greg McGary <> writes:

> Raja R Harinath <> writes:
> > Why is this necessary?  The compiler already has all the information
> > for
> > 
> >   ap = (int *) a;
> > 
> > to do what the macro does.  The exact same intent is expressed: I want
> > to treat a multidimensional array as a single-dimensional array.
> Not exactly.  `ap = (int *) a' is equivalent to `ap = (int *) &a[0]'
> and a[0] is int[10], not int[100].

My reasoning here is flawed.  Consider this:

	char a[100];
	char *s = a;

By the above argument, `s = a' is equivalent to `s = &a[0]' and a[0]
is char, not char[100], so the only valid access is to s[0], with
s[1]..s[99] being invalid.  That argument is clearly wrong in this
context, and not what BPs do in this case.


More information about the Gcc-patches mailing list