Path: utzoo!censor!isgtec!peter From: peter@isgtec.UUCP (Peter Curran) Newsgroups: comp.lang.c Subject: Re: Zero Length Arrays Allowed in C Standard? Message-ID: <246@isgtec.UUCP> Date: 13 Dec 89 18:09:48 GMT References: <2298@jato.Jpl.Nasa.Gov> <11715@smoke.BRL.MIL> <480@codonics.COM> <70188@psuecl.bitnet> <12468@ulysses.homer.nj.att.com> <233@isgtec.UUCP> Reply-To: peter@isgtec.UUCP (Peter Curran) Organization: ISG Technologies Inc., Mississauga, Ontario Lines: 15 This is a re-posting, due to technical difficulties. WIthout repeating all the discussion, much of this topic has been centred around a single zero-length array in a structure, for which the actual size is to be determined when an instance is malloc'd. The Rationale document (my copy is X3J11/88-091, 13 May 1988), in section 3.5.4.2, pp. 54-55, suggests the use of array size "1". This works just as well as zero, except you have to subtract 1 (or sizeof(elt[0])) from the amount malloc'd (except for the most common use, a variable-length string, where the initial element accounts for the terminating NUL). I realize the Rationale is not part of the standard, but I think it would take an awfully brave implementor to disallow a construct that the Rationale condones.