template <typename Tp> auto id() { } template <typename T> void g(T) { } int main() { // id<int>; g(id<int>); } G++ fails to resolve id<int> in the call. over.cc: In function ‘int main()’: over.cc:8:14: error: no matching function for call to ‘g(<unresolved overloaded function type>)’ g(id<int>); ^ over.cc:3:28: note: candidate: template<class T> void g(T) template <typename T> void g(T) { } ^ over.cc:3:28: note: template argument deduction/substitution failed: over.cc:8:14: note: couldn't deduce template parameter ‘T’ g(id<int>); ^ It works if the reference to id<int> is uncommented, or if auto id() is changed to void id()
*** Bug 78882 has been marked as a duplicate of this bug. ***
Shouldn't the status be confirmed?
It is confirmed, and has been since 2014-12-08. If you look at the dropdown you'll see there is no CONFIRMED status in GCC's bugzilla.
(In reply to Jonathan Wakely from comment #0) > It works if the reference to id<int> is uncommented, or if auto id() is > changed to void id() Or by adding something else to trigger the instantiation of the right specialization, e.g. using F = decltype(id<int>); Slightly reduced (it doesn't matter if g has a deduced return type): template <typename Tp> auto id() { } template <typename T> void g(T) { } int main() { // id<int>; // using F = decltype(id<int>); g(id<int>); }
(In reply to Jonathan Wakely from comment #4) > Slightly reduced (it doesn't matter if g has a deduced return type): Oops, it already wasn't deduced ... I confused myself with a new testcase I was trying!
*** Bug 85499 has been marked as a duplicate of this bug. ***
*** Bug 69260 has been marked as a duplicate of this bug. ***
Slightly different testcase from PR 69620 which is probably the same issue: struct function { template<typename F> function(F); }; template <typename T1, typename T2> auto sum(T1 x, T2 y) { return x + y; } template <typename T1, typename T2, typename... Targ> auto sum(T1 x, T2 y, Targ... args) { return sum(x + y, args...); } int main() { //(void)sum<int, int, int>; function f = sum<int, int, int>; } ded.cc: In function 'int main()': ded.cc:21:18: error: conversion from '<unresolved overloaded function type>' to non-scalar type 'function' requested function f = sum<int, int, int>; ^~~~~~~~~~~~~~~~~~ It works if the function is instantiated first by uncommenting the first line in main.
*** Bug 85554 has been marked as a duplicate of this bug. ***
*** Bug 96361 has been marked as a duplicate of this bug. ***
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>: https://gcc.gnu.org/g:2c58f5cadfac338a67723fd6e41c9097760c4a33 commit r11-2420-g2c58f5cadfac338a67723fd6e41c9097760c4a33 Author: Patrick Palka <ppalka@redhat.com> Date: Wed Jul 29 22:06:44 2020 -0400 c++: overload sets and placeholder return type [PR64194] In the testcase below, template argument deduction for the call g(id<int>) goes wrong because the functions in the overload set id<int> each have a yet-undeduced auto return type, and this undeduced return type makes try_one_overload fail to match up any of the overloads with g's parameter type, leading to g's template argument going undeduced and to the overload set going unresolved. This patch fixes this issue by performing return type deduction via instantiation before doing try_one_overload, in a manner similar to what resolve_address_of_overloaded_function does. gcc/cp/ChangeLog: PR c++/64194 * pt.c (resolve_overloaded_unification): If the function template specialization has a placeholder return type, then instantiate it before attempting unification. gcc/testsuite/ChangeLog: PR c++/64194 * g++.dg/cpp1y/auto-fn60.C: New test.
Should be fixed for GCC 11, thanks for the reports.
*** Bug 93317 has been marked as a duplicate of this bug. ***
*** Bug 97778 has been marked as a duplicate of this bug. ***
*** Bug 54111 has been marked as a duplicate of this bug. ***
The fix looks safe to backport; it isn't a regression, but the number of duplicate reports argue for making an exception.
The releases/gcc-10 branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>: https://gcc.gnu.org/g:4fb1ee669ccaad16795baf25d2cab48d8cf8c1eb commit r10-9136-g4fb1ee669ccaad16795baf25d2cab48d8cf8c1eb Author: Patrick Palka <ppalka@redhat.com> Date: Wed Jul 29 22:06:44 2020 -0400 c++: overload sets and placeholder return type [PR64194] In the testcase below, template argument deduction for the call g(id<int>) goes wrong because the functions in the overload set id<int> each have a yet-undeduced auto return type, and this undeduced return type makes try_one_overload fail to match up any of the overloads with g's parameter type, leading to g's template argument going undeduced and to the overload set going unresolved. This patch fixes this issue by performing return type deduction via instantiation before doing try_one_overload, in a manner similar to what resolve_address_of_overloaded_function does. gcc/cp/ChangeLog: PR c++/64194 * pt.c (resolve_overloaded_unification): If the function template specialization has a placeholder return type, then instantiate it before attempting unification. gcc/testsuite/ChangeLog: PR c++/64194 * g++.dg/cpp1y/auto-fn60.C: New test. (cherry picked from commit 2c58f5cadfac338a67723fd6e41c9097760c4a33)
*** Bug 86826 has been marked as a duplicate of this bug. ***
The releases/gcc-9 branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>: https://gcc.gnu.org/g:9499fe0403e310f4eb1f23279bff84259e120e76 commit r9-9453-g9499fe0403e310f4eb1f23279bff84259e120e76 Author: Patrick Palka <ppalka@redhat.com> Date: Wed Jul 29 22:06:44 2020 -0400 c++: overload sets and placeholder return type [PR64194] In the testcase below, template argument deduction for the call g(id<int>) goes wrong because the functions in the overload set id<int> each have a yet-undeduced auto return type, and this undeduced return type makes try_one_overload fail to match up any of the overloads with g's parameter type, leading to g's template argument going undeduced and to the overload set going unresolved. This patch fixes this issue by performing return type deduction via instantiation before doing try_one_overload, in a manner similar to what resolve_address_of_overloaded_function does. gcc/cp/ChangeLog: PR c++/64194 * pt.c (resolve_overloaded_unification): If the function template specialization has a placeholder return type, then instantiate it before attempting unification. gcc/testsuite/ChangeLog: PR c++/64194 * g++.dg/cpp1y/auto-fn60.C: New test. (cherry picked from commit 2c58f5cadfac338a67723fd6e41c9097760c4a33)
*** Bug 97999 has been marked as a duplicate of this bug. ***