Let me explain a bit more.
foo and &foo values are equivalent in C and have same type.
This is not fully correct as pointed out by the comments to the answer by @ouah. Particularly:
sizeof(foo)
is invalid, and sizeof(&foo)
is the size of a pointer.
&foo
is the pointer to foo, while &(&foo)
is invalid.
However, they are actually the same in all the other cases, as is mentioned by the standard of C (reference to, e.g., the draft of C11):
6.3.2.1.4: A function designator is an expression that has function type. Except when it is the operand of the sizeof operator or the unary & operator, a function designator with type "function returning type" is converted to an expression that has type "pointer to function returning type".
The sizeof
and unary &
operators are the only two exceptions when a function designator is not converted to a pointer.
P.S. You can also find why sizeof(foo)
and &(&foo)
is invalid:
6.5.3.2.1: The operand of the unary &
operator shall be either a function designator, the result of a []
or unary *
operator, or an lvalue that designates an object that is not a bit-field and is not declared with the register storage-class specifier.
6.5.3.4.1 The sizeof
operator shall not be applied to an expression that has function type or an incomplete type, to the parenthesized name of such a type, or to an expression that designates a bit-field member.