Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.std.c++ > #647

Re: overload resolution failed

Message-ID <ktnulj$t9f$2@dont-email.me> (permalink)
Newsgroups comp.std.c++
From Bart van Ingen Schenau <bart@ingen.ddns.info.invalid>
Subject Re: overload resolution failed
Organization A noiseless patient Spider
References <ktj02j$26pu$1@news2.ipartners.pl>
Date 2013-08-06 01:51 -0600

Show all headers | View raw


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


--
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]

Back to comp.std.c++ | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

overload resolution failed Krzysztof Żelechowski <giecrilj@stegny.2a.pl> - 2013-08-05 00:20 -0600
  Re: overload resolution failed Bart van Ingen Schenau <bart@ingen.ddns.info.invalid> - 2013-08-06 01:51 -0600
    Re: overload resolution failed Křištof Želechovski <giecrilj@stegny.2a.pl> - 2014-01-06 12:36 -0800

csiph-web