On Mon, 05 Aug 2013 00:20:32 -0600, Krzysztof Żelechowski wrote:
> Given the following declarations:
>
> int f (int *), f (int);
>
> what does the expression (f (01)) evaluate to?
>
> 1. It is an unqualified function call.
>
> 2. The name is looked up and the result is ::f.
>
> 3. The set of function declarations returned by the lookup depends on
> your interpretation.
>
> 3a. Under a strict interpretation, since the lookup finds a set of fully
> qualified function *names*, the set of function *declarations* returned
> is empty and the expression (f (01)) is ill-formed.
This interpretation is incorrect.
The expression `f (01)` is parsed as a `/postfix-expression/ ( /optional-
expression-list/ )`, with the additional constraint that the postfix-
expression must be an lvalue referring to a function or have pointer to
function type.
The name lookup finds the name ::f, which perfect qualifies as an lvalue
referring to a function, because ::f was declared as being the name of a
function.
In the following overload resolution, the set of overload declarations
for the found name(s) is built. If a function name was found, this set
can never be empty.
>
> 3b. Under a permissive interpretation, we could take into account that
> function names are introduced by declarations and consider the
> declarations corresponding to the function names found by the lookup.
> But the lookup stops as soon as it finds the name declared, that means
> it considers only the declaration ::f (int *) and it would return that
> one. In that case, the expression (f (01)) is ill-formed too.
The name-lookup stops as soon as the first declaration is found, but the
rules for overload resolution (C++ 03 13.3.1.1.1/3 [over.call.func])
require that *all* overloaded declarations are used in the resolution. If
needed, the compiler must make an additional search for overloads in the
same scope as the found declaration to satisfy that requirement.
>
> The expression would be well-formed if the standard allowed to consider
> all declarations for the function names found by the lookup, which is
> currently not the case.
It is already required (and your expression is well-formed, calling int f
(int)).
Bart v Ingen Schenau