Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: Auto variable with sizeof == 0 Message-ID: <5258@mimsy.UUCP> Date: Sun, 1-Feb-87 20:53:48 EST Article-I.D.: mimsy.5258 Posted: Sun Feb 1 20:53:48 1987 Date-Received: Sun, 1-Feb-87 23:17:59 EST References: <4114@brl-adm.ARPA> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 27 In article <4114@brl-adm.ARPA> escott%deis.uci.edu@icsg.uci.edu (Scott Menter) writes: >... is there any reason why you should be able to declare an array >with zero elements as an automatic variable? Why not? It makes sense. Perhaps it should elicit a warning, since no members of that array are accessible: Valid subscripts are in the range [0..0). >What's strange is that, on the VAX, the program apparently successfully >dereferenced bar, both setting a value for "*bar" and then using that value >later. How can this be right? Just luck. >And, just for the heck of asking, does ANSI C let you make such a >declaration? There seems to be a great debate over malloc(0), with some support as well for empty arrays. It is trivial to allow either, or to disallow either; some argue in favour of `catching the programmer's mistakes for him', while others argue that the construct may not be a mistake, or may have been written by a machine, and that having special cases for zero is both unnecessary and ugly. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690) UUCP: seismo!mimsy!chris ARPA/CSNet: chris@mimsy.umd.edu