Alf P. Steinbach
unread,Jan 16, 2016, 4:38:40 PM1/16/16You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
On 1/16/2016 9:46 PM, Stefan Ram wrote:
>
> Does this mean that »the address of 'int f()' will always
> evaluate as 'true'« is false?
No. It means that the interpretion where this says that `&f` is the
value `true`, is meaningless.
> If it is false, what had the author in mind?
That the address of a function converts implicitly to `true`, and never
to `false`, since it's always non-zero.
This is also the case with the address of a variable, but iostreams have
an overload of `<<` that takes a pointer to void, which will be used
unless it's address of a `char`, which will be interpreted as a C
string. So, for data pointers the `bool` overload isn't considered.
These overloads are not considered for address of function, because
there's no implicit conversion between data pointers and function
pointers (apparently in support of Harvard architectures), and until
C++11 an implementation was not even formally allowed to support
`reinterpret_cast` between them, which was and is required by Posix, and
by the Windows API, and other in-practice programming.
Cheers & hth.,
- Alf