Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!rutgers!sri-spam!ames!oliveb!intelca!mipos3!pinkas From: pinkas@mipos3.UUCP Newsgroups: comp.lang.c Subject: Re: Auto variable with sizeof == 0 Message-ID: <409@mipos3.UUCP> Date: Wed, 4-Feb-87 13:30:53 EST Article-I.D.: mipos3.409 Posted: Wed Feb 4 13:30:53 1987 Date-Received: Sat, 7-Feb-87 08:36:48 EST References: <4114@brl-adm.ARPA> <5258@mimsy.UUCP> Reply-To: pinkas@mipos3.UUCP (Israel Pinkas) Organization: Intel, Santa Clara, CA Lines: 28 In article <5258@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes: >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). Wrong. There are no valid subscripts to the array. To allow a subscript of 0, the array must be declared as bar[1]. Remember, the valid subscripts of an array declared foo[n] are [0..n1]. Regarding this problem, in a former posting I mentioned that the declaration of struct foo **bar[] as an auto variable would be useful as a dynamic array. I have since been corrected. Someone (I deleted the mail message, so I don't have your name, sorry) pointed out that K&R stat that an array is a constant and is thus unusable as an lvalue. To make a dynamic array, the declaration should read struct foo ***bar. When malloc'ed, it will yield an array of pointers to pointers to struct foo. -Israel -- ---------------------------------------------------------------------- UUCP: {amdcad,decwrl,hplabs,oliveb,pur-ee,qantel}!intelca!mipos3!pinkas ARPA: pinkas%mipos3.intel.com@relay.cs.net CSNET: pinkas%mipos3.intel.com