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

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

Messages

Date: 2024-07-15.00:00:00

Additional notes (July, 2024)

The example in this issue is resolved by issue 2918 by suitably ordering placeholder type deduction before the address operation.

Date: 2023-06-20.19:34:52

Proposed resolution:

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

Any If there is a target, 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.
Date: 2023-06-20.19:34:52

Suggested resolution [SUPERSEDED]:

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
2024-08-01 12:33:59adminsetmessages: + msg7781
2023-06-20 19:34:52adminsetmessages: + msg7332
2023-06-20 19:34:52adminsetstatus: open -> review
2022-04-27 16:02:23adminsetmessages: + msg6809
2022-04-26 00:00:00admincreate