Auto variable with sizeof == 0

throopw at dg_rtp.UUCP throopw at dg_rtp.UUCP
Sat Feb 7 08:19:43 AEST 1987


> chris at mimsy.UUCP (Chris Torek)
>> escott%deis.uci.edu at icsg.uci.edu (Scott Menter)

>>... is there any reason why you should be able to declare an array
>>with zero elements as an automatic variable?
> Why not?  It makes sense.  [...]
> some argue in favour of `catching the programmer's
> mistakes for him', while others argue that the construct may not
> be a mistake, or may have been written by a machine, and that having
> special cases for zero is both unnecessary and ugly.

This is sensible, I agree.  But it is worth noting that

        int foo[0];
and
        int foo[];

are NOT the same thing.  Even if X3J11 were to take the reasonable
approach and allow the first as an automatic declaration, the second
should still be an error as an automatic declaration.

--
IBM manuals are written by little old ladies in Poughkeepsie who are
instructed to say nothing specific.
                                --- R. T. Lillington
-- 
Wayne Throop      <the-known-world>!mcnc!rti-sel!dg_rtp!throopw



More information about the Comp.lang.c mailing list