Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!umich!samsung!think!snorkelwacker!spdcc!ima!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: "array" vs. "&array" ? Message-ID: <15672@haddock.ima.isc.com> Date: 17 Jan 90 01:25:26 GMT References: <24521@gryphon.COM> <21764@mimsy.umd.edu> <5248@buengc.BU.EDU> <15638@haddock.ima.isc.com> <5260@buengc.BU.EDU> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Cambridge, MA 02138-5302 Lines: 27 In article <5260@buengc.BU.EDU> bph@buengc.bu.edu (Blair P. Houghton) writes: >In article <15638@haddock.ima.isc.com> karl@haddock.ima.isc.com (Karl Heuer) writes: >>In article <5248@buengc.BU.EDU> bph@buengc.bu.edu (Blair P. Houghton) writes: >>>Usually when you ask for the pointer to an array you get a >>>pointer to the first element of the array. >> >>No, you get a pointer to the entire array (in ANSI C) or an error (in K&R >>C), except in those pre-ANSI compilers that chose, as an extension, to make >>the misinterpretation you describe (usually accompanied by a warning). > >"those...that chose" happens to describe all the compilers I can find >(three different pre-ansi, one ansi-I-think (it's gcc with the ansi >switch turned on...)). As I said, in ANSI C you get a pointer to the entire array. You claim that gcc gives you a pointer to the first element instead. I don't think you've tested it in a way that would distinguish those two results. A pointer to an entire array and a pointer to the first element, after being converted to a common type, will compare equal. Exercise: design a program that will print "ANSI" if the compiler defines &a as I described, or "non-ANSI" if it simply ignores the &. Compile it with gcc and at least one pre-ANSI compiler, and tell us what you find. Karl W. Z. Heuer (karl@haddock.isc.com or ima!haddock!karl), The Walking Lint (I'll skip the rest of the article, since I don't think we're talking on the same wavelength yet.)