You somehow understood it backwards. On the contrary, function type automatically decays to function pointer type unless the function identifier is used under sizeof
or &
.
Again, under sizeof
and &
function type does not decay to pointer. In all other cases it decays to pointer type. (This, in turn, leads to the fact that applying sizeof
to functions is illegal.)
The behavior of function types in C mirrors the well-known behavior of array types: unless you use them under sizeof
or &
, they are immediately and implicitly converted to pointer types.
This means in your examples expressions &foo
and foo
are equivalent. In the first case the pointer is produced by the explicit application of &
. In the second case, the pointer is produced by the implicit "function type decay" feature. The pointer value is the same in both cases.