Path: utzoo!utgpu!water!watmath!clyde!rutgers!mit-eddie!uw-beaver!cornell!rochester!ur-tut!sunybcs!boulder!hao!ames!amdcad!sun!pitstop!sundc!seismo!uunet!mcvax!ukc!reading!onion!riddle!domo From: domo@riddle.UUCP (Dominic Dunlop) Newsgroups: comp.lang.c Subject: Re: Address of Array Summary: I thought I knew about lvalues -- then I discovered ANSI Keywords: lvalue, modifiable lvalue, & operator Message-ID: <536@riddle.UUCP> Date: 23 Dec 87 15:57:31 GMT References: <126@citcom.UUCP> <2550034@hpisod2.HP.COM> <1854@haddock.ISC.COM> <1442@houdi.UUCP> <9735@mimsy.UUCP> Reply-To: domo@riddle.UUCP (Dominic Dunlop) Organization: Sphinx Ltd., Maidenhead, England Lines: 45 In article <9735@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes: [Quotes from other postings deleted] >Given the declaration > > int a[10]; > >the following is true: > > 0. &a is currently illegal > 1. &a will be legal in the near future. [Further points and examples deleted] Well, I didn't agree with point 1. Looking at the November 9 draft of the proposed ANSI standard, I found that it says concisely in 3.3.3.2 -- Address and Indirection Operators: The operand of the unary & operator shall either be a function designator or an lvalue that designates an object that is not a bit-field and is not declared with the register storage class specifier. This confirmed my prejudice, namely that & applied to an object of array type is an error. But then I looked in 3.2.2.1 -- Lvalues and function designators: An lvalue is an expression ... that designates an object... A modifiable lvalue is an lvalue that does not have array type... Except when it is the operand of the sizeof operator or the unary & operator, or is a string literal used to initialize an array of characters, an lvalue which has type ``array of type'' is converted to an expression that has type ``pointer to type'' that points to the initial member of the array object and is not an lvalue. To summarize, an array can now be an lvalue, albeit not a modifiable one, and consequently, the & operator can be applied to it. The draft does not explicitly say what happens when the operator is so applied. I assume that the address of the whole array is delivered, and that the type of the result is ``pointer to array of ...'' What on earth are the consequences of this, and why was it done? Who needs a ``pointer to array of ...'' Enlightenment, please... -- Dominic Dunlop domo@sphinx.co.uk domo@riddle.uucp