Title
Argument-dependent lookup is for a name
Status
open
Section
6.5.4 [basic.lookup.argdep]
Submitter
CWG

Created on 2026-04-25.00:00:00 last changed 1 week ago

Messages

Date: 2026-05-02.19:54:29

Possible resolution:

Change in 6.5.4 [basic.lookup.argdep] paragraph 4 as follows:

The associated namespaces for a call are the innermost enclosing non-inline namespaces for its associated entities as well as every element of the inline namespace set (9.9.2 [namespace.def]) of those namespaces. Argument-dependent lookup for a name N finds all declarations of functions and function templates named N that
  • are found by a search of for N in any associated namespace, or
  • are declared as a friend (11.8.4 [class.friend]) of any class with a reachable definition in the set of associated entities, or
  • are exported, are attached to a named module M (10.2 [module.interface]), do not appear in the translation unit containing the point of the lookup, and have the same innermost enclosing non-inline namespace scope as a declaration of an associated entity attached to M (6.7 [basic.link]).
If the lookup is for a N is dependent name (13.8.3 [temp.dep], 13.8.4.2 [temp.dep.candidate]), the above lookup is also performed from each point in the instantiation context (10.6 [module.context]) of the lookup, additionally ignoring any declaration that appears in another translation unit, is attached to the global module, and is either discarded (10.4 [module.global.frag]) or has internal linkage.
Date: 2026-04-25.00:00:00

(From submission #891.)

Consider:

  namespace N {
    struct C {
      friend void f(C);
      friend void g(C);
    };
  }

  void h() {
    f(N::C{});
  }

According to 6.5.4 [basic.lookup.argdep] paragraph 4, argument-dependent lookup finds functions without considering their names (such as g in the example above). This is misguided.

History
Date User Action Args
2026-05-02 19:41:20adminsetmessages: + msg8564
2026-04-25 00:00:00admincreate