Keep looking at it.
Printable View
Are you expecting it to change it's wording, Dave?
If you have some reliable source to the contrary, I'd like to hear it and know who that source was.
Anyone got something besides hand waving that authoritatively disagrees?
Question 6.2 of the C FAQ, maintained by comp.lang.c (http://c-faq.com/aryptr/aryptr2.html) is worded virtually the same way as maven's post. There is also the mov statement in assembly which moves a constant or an offset into a register; the compiler may very well generate that code, so you are being a bit too pedantic in this case.
This belief is not worth subscribing to either. Pointers and arrays are different enough to treat them as seperate data structures. Arrays simply degrade into pointers to make it possible to use arrays throughout your code, but that only happens in very common, specific situations. Read http://c-faq.com/aryptr/aryptrequiv.html
Agree with your remark about the mov statement - but that's not the subject, at all.
I'll let K&R provide the quote, from "The C Programming Language", page 99:
"In evaluating a[i], C converts it to *(a + i) immediately; the two forms are equivalent."
and "As the other side of this coin, if pa is a pointer, expressions may use it with a subscript; pa[i] is identical to *(pa+i). In short, an array-and-index expression is equivalent to one written as a pointer and offset."
In short, there ARE no arrays in C, except for that brief instant until C changes them into pointers with a non-variable construction. Arrays are just an artificial construct to help us poor humans who can't keep hundreds or thousands of memory addresses straight, while we're coding, with our favorite C compiler.
I have no idea who wrote (or maintains), the C-FAQ you mentioned, but I'll stick with K&R, thanks. :D
No one disagrees with the quoted, but this doesn't support what you go on to say here:
In long, yes, arrays do exist. Arrays are an lvalue, they have a location in memory. But that very location is irrelevant until you start to use pointers, and an array's location is also very different. The key difference between arrays and pointers is that, even though an array structure may be implemented with pointer registers, arrays are not reassigned, resized, or NULLed like pointers may; that is to say, pointers are modifiable lvalues according to the standard.Quote:
In short, there ARE no arrays in C, except for that brief instant until C changes them into pointers with a non-variable construction. Arrays are just an artificial construct to help us poor humans who can't keep hundreds or thousands of memory addresses straight, while we're coding, with our favorite C compiler.
However, no matter how many times you point to an array, it will not modify the array's type. The array's original location is where it always was. Therefore, there is a distiction to be made and it's important enough: basically because it allows compilers to set aside registers for the array structure at compile time (because their size and location is constant) as opposed to run time. An int *, for example, may contain the address of array[10]'s zeroeth element, but the array structure is actually ten registers for use by integers, and only indexed or otherwise accessed by a pointer containing one of those addresses.
I can provide chapter and verse:Quote:
I have no idea who wrote (or maintains), the C-FAQ you mentioned, but I'll stick with K&R, thanks. :D
Thread over?Quote:
Originally Posted by The Standard 3.2.2.1
No...
Not at all, which is why I urged you to keep looking at it.
This comes too close to "an array is a pointer" for me.
And this seems to be your shortcut conclusion as well.
There are important differences, and I feel it is worth understanding them. That FAQ highlights one aspect.