Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!samsung!uakari.primate.wisc.edu!ames!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: Zero Length Arrays Allowed in C Standard? Message-ID: <11760@smoke.BRL.MIL> Date: 6 Dec 89 21:10:32 GMT References: <480@codonics.COM> <2678@cbnewsj.ATT.COM> Reply-To: gwyn@brl.arpa (Doug Gwyn) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 21 In article <2678@cbnewsj.ATT.COM> asd@cbnewsj.ATT.COM (adam.denton,mt,) writes: >What fathomable purpose could a programmer possibly want by >declaring a zero-length array? To store nothing? What fathomable purpose could a programmer possibly want by coding a loop that gets executed zero times? To do nothing? Possible uses for zero-sized objects (notably arrays) have already been posted. Let me add that there are no logical problems with the concept; all properties of such objects would be well defined. sizeof zero would be 0 &zero points at the object ++ptr_to_zero would still point to zero *ptr_to_zero needn't do anything to "access" the contents &zero_length_array[0] points one past the last valid element etc. As I recall, zero was invented by Arabic mathematicians thousands of years ago. It's a pity it still frightens or confuses people.