https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102721
Bug ID: 102721
Summary: out-of-line member function definition fails to allow
lambda in unevaluated-context of new feature in c++20
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: nickhuang99 at hotmail dot com
Target Milestone: ---
The following snippet code exposes that GCC parser doesn't comply with c++20
standard to allow lambda in unevaluated context. It seems this out-of-line
definition creates a new lambda type where lambda as operand of "decltype"
should be treated as in unevaluated context. So, it shouldn't create a new
lambda type in out-of-line definition.
Both clang and MSVC++ (https://www.godbolt.org/z/EMbb44fd8) parse this
correctly.
(with "-std=c++20")
template<class T>
struct A
{
void foo(const T){}
};
template<>
void A<decltype(+[]{})[3]>::foo(const decltype(+[]{})[3])
{}
<source>:9:6: error: ambiguating new declaration of 'void A<void (*
[3])()>::foo(void (* const*)())'
9 | void A<decltype(+[]{})[3]>::foo(const decltype(+[]{})[3])
| ^~~~~~~~~~~~~~~~~~~~~
<source>:5:10: note: old declaration 'void A<T>::foo(T) [with T = void (*
[3])()]'
5 | void foo(const T){}
| ^~~