This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 116a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2024-12-19
(From submission #516.)
Consider:
template <typename T> int f(T&&); void g(); // #1 template <typename T> void g(); // #2 int x = f(&g);
All major implementations reject. However, 12.3 [over.over] paragraph 3 seems to say that templates are ignored if template argument deduction fails ("if any"):
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.
For the following example, prior core issues 2608 and 2848 have indicated that "deduction" should always consider default template arguments. Yet, only gcc accepts the example.
template<typename T> int f(T); template<typename T = int> void g(); int x = f(&g);
See also issue 2572.
Subclause 13.10.3.6 [temp.deduct.type] bullet 5.6.3 makes the parameter of f a non-deduced context for these situations. However, 13.10.2 [temp.arg.explicit] paragraph 4 allows omitting the template argument list if all template parameters can be deduced or obtained from default template arguments. Thus, &g can be considered to refer to both a function template and a function template specialization.
The special treatment in overload resolution for f yields inconsistent outcomes where overload resolution is not applied:
void g(int);
void g(auto);
decltype(&g) p; // rejected by implementations for no reason in the wording