Title
Address of overloaded function with no target
Status
open
Section
12.3 [over.over]
Submitter
Jason Merrill

Created on 2022-04-26.00:00:00 last changed 7 months ago

Messages

Date: 2022-04-27.16:02:23

Suggested resolution:

Change in 12.3 [over.over] paragraph 5 as follows:

Any given function template specialization F1 is eliminated if the set contains a second function template specialization whose function template is more specialized better than the function template of F1. If there is no target, a function template is better than another if it is more constrained than the other; otherwise a function template is better than another if it is more specialized than the other according to the partial ordering rules of 13.7.7.3 [temp.func.order]. After such eliminations, if any, there shall remain exactly one selected function.
Date: 2022-04-26.00:00:00

Consider:

  template <class T> T f(T);   // #1
  template <class T> T* f(T*); // #2
  auto p = &f<int>;

Accoring to 12.3 [over.over] paragraph 3 and 12.3 [over.over] paragraph 5:

The specialization, if any, generated by template argument deduction (13.10.4 [temp.over], 13.10.3.3 [temp.deduct.funcaddr], 13.10.2 [temp.arg.explicit]) for each function template named is added to the set of selected functions considered.

[...]

Any given function template specialization F1 is eliminated if the set contains a second function template specialization whose function template is more specialized than the function template of F1 according to the partial ordering rules of 13.7.7.3 [temp.func.order]. After such eliminations, if any, there shall remain exactly one selected function.

Major implementations reject the example as ambiguous, yet the wording specifies to unambiguously choose #2.

History
Date User Action Args
2022-04-27 16:02:23adminsetmessages: + msg6809
2022-04-26 00:00:00admincreate