Zero Length Arrays Allowed in C Standard?

Craig Jackson drilex1 dricejb at drilex.UUCP
Sun Dec 10 02:00:21 AEST 1989


In article <7227 at ficc.uu.net> peter at ficc.uu.net (Peter da Silva) writes:
>In article <7349 at quick.COM> srg at quick.COM (Spencer Garrett) writes:
>> But this "convenience" is in no way implementation specific.  It is
>> cleanly implementable in any environment which is capable of hosting
>> C at all.
>
>Including the infamous Burroughs A-series processors?
>`-_-' Peter da Silva. +1 713 274 5180. <peter at ficc.uu.net>.
> 'U`  Also <peter at ficc.lonestar.org> or <peter at sugar.lonestar.org>.

I think the "convenience" referred to was the practice of putting an
array of length 1 (in the absence of zero-length arrays) at the end
of the structure.  You may rest assured that A-Series C will handle
this as well as the next compiler.  Which means that if you malloc'ed the
space, the malloc'ed size is what matters.

The implementors of A-Series C knew that this sort of thing was rampant,
and therefore implemented pointed-to objects using a simulated linear address
space.

They do special-case things which are not pointed to; if one declares an
array:
   int a[1];
and *never* point to it, then referencing a[1] will get you an interrupt.

Note: because of this pointed-to rule, a[1] and *(a+1) can have dramatically
different compilations.
-- 
Craig Jackson
dricejb at drilex.dri.mgh.com
{bbn,axiom,redsox,atexnet,ka3ovk}!drilex!{dricej,dricejb}



More information about the Comp.lang.c mailing list