Title
Default arguments on different declarations for the same function and the Koenig lookup
Status
dup
Section
6.5.4 [basic.lookup.argdep]
Submitter
Daveed Vandevoorde

Created on 1998-10-24.00:00:00 last changed 307 months ago

Messages

Date: 1999-04-15.00:00:00

Rationale (04/99): The proposal would also apply to local using-declarations (per Mike Ball) and was therefore deemed undesirable. The ambiguity issue is dealt with in Core issue 1

Date: 2022-02-18.07:47:23

Given the following test case:

    enum E { e1, e2, e3 };

    void f(int, E e = e1);
    void f(E, E e = e1);

    void g() {
        void f(long, E e = e2);
        f(1); // calls ::f(int, E)
        f(e1); // ?
    }

First note that Koenig lookup breaks the concept of hiding functions through local extern declarations as illustrated by the call `f(1)'. Should the WP show this as an example?

Second, it appears the WP is silent as to what happens with the call `f(e1)': do the different default arguments create an ambiguity? is the local choice preferred? or the global?

Tentative Resolution (10/98) In 6.5.4 [basic.lookup.argdep] paragraph 2, change

If the ordinary unqualified lookup of the name finds the declaration of a class member function, the associated namespaces and classes are not considered.
to
If the ordinary unqualified lookup of the name finds the declaration of a class member function or the declaration of a function at block scope, the associated namespaces and classes are not considered.

Rationale (04/99): The proposal would also apply to local using-declarations (per Mike Ball) and was therefore deemed undesirable. The ambiguity issue is dealt with in Core issue 1

History
Date User Action Args
1999-09-14 00:00:00adminsetmessages: + msg183
1999-09-14 00:00:00adminsetstatus: review -> dup
1998-10-24 00:00:00admincreate