Zero Length Arrays Allowed in C Standard?

Doug Gwyn gwyn at smoke.BRL.MIL
Sat Dec 2 18:41:21 AEST 1989


In article <480 at codonics.COM> bret at codonics.com (Bret Orsburn) writes:
>In article <11715 at smoke.BRL.MIL> gwyn at brl.arpa (Doug Gwyn) writes:
>>In article <2298 at jato.Jpl.Nasa.Gov> baalke at mars.jpl.nasa.gov (Ron Baalke) writes:
>>>are zero length arrays allowed in the ANSI standard for C?
>>No; Standard C does not support zero-sized objects.
>Aargh! Whatever happened to "don't break existing code"?!
>What was the rationale behind this (IMHO) arbitrary obstruction?

Many existing C compilers do not support 0-sized objects,
so this is not a "change to C".  K&R1 was not explicit about this
and so offer no guidance; indeed, taken literally K&R1 prohibits
use of the name of a 0-length array in expressions (although the
C Standard fixed the thing that caused a problem there), and also
permits negative constants for array lengths in declarations.

There are several technical problems that would have to be overcome
if 0-sized objects were allowed in C.  (I don't want to discuss them
in this forum.)  As a proponent of zero-sized objects, I don't think
these obstacles are insurmountable, but given the lack of a clear
need, X3J11 decided not to open that can of worms.



More information about the Comp.lang.c mailing list