Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!mailrus!uflorida!haven!mimsy!chris From: chris@mimsy.umd.edu (Chris Torek) Newsgroups: comp.lang.c Subject: Re: "array" vs. "&array" ? Message-ID: <21727@mimsy.umd.edu> Date: 10 Jan 90 08:05:56 GMT References: <1989Dec22.013757.3086@sj.ate.slb.com> <571@mwtech.UUCP> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 30 >> float arrf[3] = {1.2,2.3,3.4}; >> arrf; /*evaluates to pointer to float according to K&R*/ [note that this is because of a special case: `arrf' is an where a value is needed.] In article chuckp@ncr-fc.FtCollins.NCR.com (Chuck Phillips) writes: >When declaring/defining arrf, space is allocated for a pointer to the array >_in the symbol table_, _not_ in the actual object code. This is bogus. The C language is not necessarily compiled, and even if it is, the language itself does not claim anything about a `symbol table'. If a compiler emits correct code purely by divine guidance and has no memory at all, it can still be a C compiler. Again, `float *p; p = arrf;' puts `arrf' in value context, so a C compiler is obliged to generate whatever code it takes to store the address of the first (0'th) element of the array in the object `p'. This address is stored in whatever representation is used for the type `float *'. In New (ANSI) C, `float (*q)[3]; q = &arrf;' has `arrf' in an object context, not a value context; the `&' applies, and a C compiler is obliged to generate whatever code it takes to store the address of the entire array in the object `q'. This address is stored in whatever representation is used for the type `float (*)[3]'. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@cs.umd.edu Path: uunet!mimsy!chris