This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Zero-length arrays


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]