Zero-length arrays
Fergus Henderson
fjh@cs.mu.oz.au
Fri Jan 5 18:03:00 GMT 2001
On 04-Jan-2001, Linus Torvalds <torvalds@transmeta.com> wrote:
> (I never understood why C had that silly "you can't have a zero-length
> array" rule. Even if there were no real reasons to use them, it still
> has a clear and unambiguous conceptual meaning)
I've argued against that rule at length in comp.std.c/c++,
and while I still don't agree with the decision to keep the rule,
I am at least familiar with the arguments for its retention.
One argument is that using it breaks code which does
int array_size = sizeof(array)/sizeof(array[0]);
Another argument is that it breaks the invariant that every object
has a unique address.
--
Fergus Henderson <fjh@cs.mu.oz.au> | "I have always known that the pursuit
| of excellence is a lethal habit"
WWW: < http://www.cs.mu.oz.au/~fjh > | -- the last words of T. S. Garp.
More information about the Gcc
mailing list