Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!sunybcs!rutgers!att!cbnewsj!asd From: asd@cbnewsj.ATT.COM (adam.denton) Newsgroups: comp.lang.c Subject: Re: Zero Length Arrays Allowed in C Standard? Message-ID: <2678@cbnewsj.ATT.COM> Date: 6 Dec 89 17:08:21 GMT References: <480@codonics.COM> Reply-To: asd@cbnewsj.ATT.COM (adam.denton,mt,) Organization: AT&T Bell Laboratories Lines: 40 In article <480@codonics.COM> bret@codonics.com (Bret Orsburn) writes: >In article <11715@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn) writes: >>In article <2298@jato.Jpl.Nasa.Gov> baalke@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? Pardon me, but I just can't keep quiet any longer. What fathomable purpose could a programmer possibly want by declaring a zero-length array? To store nothing? Just what is a compiler supposed to do when it sees int a[0]; ?? Set `a' to point somewhere in memory (i.e., "allocate" this "array") ? But since it's a zero-length object, the compiler might well assign ANOTHER variable's location to that same somewhere in memory. And how could I assign something to that location (which is dubious anyway%)? C never allows assignment to the name of an array. `a' is not an lvalue. And a[0] is not a member of the array `a' !! (or a[_anything_] for that matter!!) I suspect the a[0] that the original poster found was a typo that was never detected. [End of my sermon on the mount.] ------- % Akin to { int *p; *p = 3; } without p being malloc'ed. ------- Adam S. Denton asd@mtqua.ATT.COM All flames are appreciated! Please enclose $1.00 per flame to cover processing and handling!!