https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107390
Bug ID: 107390
Summary: template-nested lambda type uniqueness
Product: gcc
Version: 12.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: development at jordi dot vilar.cat
Target Milestone: ---
type obtained from a lambda (with c++20 decltype()) nested into a template
(either class o function) is not resolved as a unique type, making this simple
code to fail (compiled with g++-12 -std=c++20):
#include <type_traits>
template<typename> struct test1
{
using type0 = decltype([]{});
using type1 = std::type_identity_t<type0>;
static_assert(std::is_same_v<type0, type1>);
};
template<typename> void test2()
{
using type0 = decltype([]{});
using type1 = std::type_identity_t<type0>;
static_assert(std::is_same_v<type0, type1>);
}
int main(int, char**)
{
test1<void>{};
test2<void>();
}
both static_assert fail identically:
error: static assertion failed
8 | static_assert(std::is_same_v<type0, type1>);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
<source>:8:24: note: 'std::is_same_v<test1<void>::<lambda()>,
test1<void>::<lambda()> >' evaluates to false
<source>:16:24: error: static assertion failed
16 | static_assert(std::is_same_v<type0, type1>);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
<source>:16:24: note: 'std::is_same_v<test2<void>()::<lambda()>,
test2<void>()::<lambda()> >' evaluates to false
This compiles correctly if lambdas are not nested inside a template.