Zero Length Arrays Allowed in C Standard?

Doug Gwyn gwyn at smoke.BRL.MIL
Thu Dec 7 07:20:49 AEST 1989


In article <8141 at cg-atla.UUCP> fredex at cg-atla.UUCP (Fred Smith) writes:
-One reason that comes to mind is a conflict with the way arrays 
-relate to pointers. For normal arrays, simply mentioning its name
-in a program evaluates to the address of the array. Now what is this
-address??  It is the address of the first element of the array! If
-the thing is declared as zero length, what do you get when you
-mention its address ??  I dunno, haven't tried it yet (I intend to),
-but I bet it makes no sense, whatever it is!

It makes perfect sense.

-Even if it does evaluate to some address somewhere, it certainly is
-not an address at which one would dare to store data

This is no different from usual -- you're not allowed to store beyond
the bounds of ANY array.

The main problem is that two distinct 0-length objects might have
the same address.  This bothers some people.



More information about the Comp.lang.c mailing list