https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95010
Bug ID: 95010
Summary: Recursive function template with function parameter of
type decltype([]{}) is rejected
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ppalka at gcc dot gnu.org
Target Milestone: ---
$ cat testcase.C
template<typename T>
void foo(decltype([]{}) *s) {
if (0)
foo<T>(s);
}
void bar() {
foo<int>(nullptr);
}
$ g++ -std=c++2a testcase.C
testcase.C: In instantiation of ‘void foo(decltype (<lambda>)*) [with T = int;
decltype (<lambda>) = foo<int>::<lambda()>]’:
testcase.C:8:19: required from here
testcase.C:4:12: error: cannot convert ‘<lambda()>*’ to ‘<lambda()>*’
4 | foo<T>(s);
| ^
| |
| <lambda()>*
testcase.C:2:26: note: initializing argument 1 of ‘void foo(decltype
(<lambda>)*) [with T = int; decltype (<lambda>) = foo<int>::<lambda()>]’
2 | void foo(decltype([]{}) *s) {
| ~~~~~~~~~~~~~~~~^
We should also accept:
template<typename T>
void foo(decltype([]{}) *s, decltype(s) q) {
foo<T>(q, s);
}
void bar() {
foo<int>(nullptr, nullptr);
}