sizeof( &array )
sizeof( array )
&*( array + 0 )
array + 0
Edit: (&* array) will also give a pointer.
This is just a really convoluted way to write 2:
&array - &array
&*(array+2) - &*(array+0)
(array+2) - (array+0)
2 - 0
"The sizeof operator... When applied to an operand that has array type, the result is the total number of bytes in the array."
"Except when it is the operand of the sizeof operator or the unary & operator, or is a character string literal used to initialize an array of character type, or is a wide string literal used to initialize an array with element type compatible with wchar_t, an lvalue that 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."
Additionally, here is a thread of Linus Torvalds pointing out even more of the confusing nature of arrays and sizeof in C:
I really like the idiom for passing sized arrays suggested at the end of that LKML thread: pass them by reference!
void func(int (*arr))
printf("arr size: %ld\n", sizeof(*arr));
So your reasoning is not quite correct, it should really be that you think of
sizeof( &array )
sizeof( &(something) )
Another slightly confusing aspect is that `&array` gives you a "pointer to array" (which has the same value as `&array`, but is of a different type). Most importantly, it behaves differently in pointer arithmetic (the implied offset is the size of the array, rather than the size of its elements).
&array and array decay to the same thing, the pointer to the first element if they are used in an expression. But sizeof gives a different result, because array+0 'decays' to a pointer, and array doesn't.