Title
Missing cases for reference and array types for argument-dependent lookup
Status
review
Section
6.5.4 [basic.lookup.argdep]
Submitter
Lewis Baker

Created on 2024-04-30.00:00:00 last changed 6 months ago

Messages

Date: 2024-05-01.20:48:31

Suggested resolution:

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

For each argument type T in the function call, there is a set of zero or more associated entities to be considered. The set of entities is determined entirely by the types of the function arguments (and any template template arguments). Any typedef-names and using-declarations used to specify the types do not contribute to this set. The set of associated entities for a type T is determined in the following way:
  • If T is a fundamental type, its associated set of associated entities is empty.
  • If T is a class type (including unions), its associated entities are: the class itself; the class of which it is a member, if any; and, if it is a complete type, its direct and indirect base classes. Furthermore, if T is a class template specialization, its associated entities also include: the entities associated with the types of the template arguments provided for template type parameters; the templates used as template template arguments; and the classes of which any member templates used as template template arguments are members. [Note 2: Non-type template arguments do not contribute to the set of associated entities. —end note]
  • If T is an enumeration type, its associated entities are T and, if it is a class member, the member's class.
  • If T is a pointer to cv U, a reference to cv U, or an array of U, its associated entities are those associated with U.
  • If T is a function type, its associated entities are those associated with the function parameter types and those associated with the return type.
  • If T is a pointer to a member function of a class X, its associated entities are those associated with the function parameter types and return type, together with those associated with X.
  • If T is a pointer to a data member of class X, its associated entities are those associated with the member type together with those associated with X.
The associated entities of a function call is the union of the associated entities of the types of the arguments to the function call. In addition, if the argument is an overload set or the address of such a set, its associated entities are the union of those associated with each of the members of the set, i.e., the entities associated with its parameter types and return type. Additionally, if the aforementioned overload set is named with a template-id, its associated entities also include its template template-arguments and those associated with its type template-arguments.
Date: 2024-05-31.21:07:31

The specification for associated entities in argument-dependent lookup recurses into template argument types, but misses handling reference and array cases. Those cannot appear for function arguments. For example:

  namespace N {
    template<typename T>
    struct A {
      operator T() const noexcept;
    };
  }
  namespace M {
    struct B {};
    void f(B&);
  }

  void caller() {
    N::A<M::B&> arg;
    f(arg);
  }

Possible resolution:

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

For each argument type T in the function call, there is a set of zero or more associated entities to be considered. The set of entities is determined entirely by the types of the function arguments (and any template template arguments). Any typedef-names and using-declarations used to specify the types do not contribute to this set. The set of associated entities for a type cv T is determined in the following way:
  • If T is a fundamental type, its associated set of associated entities is empty.
  • If T is a class type (including unions), its associated entities are: the class itself; the class of which it is a member, if any; and, if it is a complete type, its direct and indirect base classes. Furthermore, if T is a class template specialization, its associated entities also include: the entities associated with the types of the template arguments provided for template type parameters; the templates used as template template arguments; and the classes of which any member templates used as template template arguments are members. [Note 2: Non-type template arguments do not contribute to the set of associated entities. —end note]
  • If T is an enumeration type, its associated entities are T and, if it is a class member, the member's class.
  • If T is a pointer to U, a reference to U, or an array of U, its associated entities are those associated with U.
  • If T is a function type, its associated entities are those associated with the function parameter types and those associated with the return type.
  • If T is a pointer to a member function of a class X, its associated entities are those associated with the function parameter types and return type, together with those associated with X.
  • If T is a pointer to a data member of class X, its associated entities are those associated with the member type together with those associated with X.
In addition, if the argument is an overload set or the address of such a set, its associated entities are the union of those associated with each of the members of the set, i.e., the entities associated with its parameter types and return type. Additionally, The associated entities of a function call are the associated entities of each argument A of the call, consisting of
  • if A is an id-expression whose terminal name refers to an overload set O, the union of the associated entities of the function types of the members of O, and
  • if the aforementioned overload set is named with A is a template-id I whose terminal name refers to an overload set, its associated entities also include its the template template-arguments of I and those the associated with its entities of each type template-arguments. template-argument of I, and
  • otherwise, if A has a type, the associated entities of the type of A,
  • otherwise, A has no associated entities.
History
Date User Action Args
2024-05-31 21:07:31adminsetstatus: open -> review
2024-05-01 20:48:31adminsetmessages: + msg7686
2024-04-30 00:00:00admincreate