https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93317
Bug ID: 93317
Summary: return type deduction fails for templated unary
function
Product: gcc
Version: 9.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: [email protected]
Target Milestone: ---
The following legal code will not compile as template deduction failed, see
https://godbolt.org/z/AHUHpF
================================
template<typename T>
auto func(const T& t)
// -> T //mentioning the return type works again
{ return t; }
template<typename Func>
void apply(Func f) {}
int main() {
apply(func<int>);
}
================================
As stated, there is a workaround, namely mentioning the return type (only if
possible, of course).