Here, the capture proxy for *this is const, but its DECL_VALUE_EXPR is not.
Don't ICE on this; it's a reasonable difference, since in C++ an rvalue of
scalar type does not have cv-qualifiers.
gcc/cp/ChangeLog:
PR c++/95193
* pt.c (tsubst_decl): Relax assert.
gcc/testsuite/ChangeLog:
PR c++/95193
* g++.dg/cpp1z/lambda-this7.C: New test.
&& DECL_BIT_FIELD_TYPE (TREE_OPERAND (ve, 1)) == type)
type = TREE_TYPE (ve);
else
- gcc_checking_assert (TREE_TYPE (ve) == type);
+ gcc_checking_assert (TYPE_MAIN_VARIANT (TREE_TYPE (ve))
+ == TYPE_MAIN_VARIANT (type));
SET_DECL_VALUE_EXPR (r, ve);
}
if (CP_DECL_THREAD_LOCAL_P (r)
--- /dev/null
+// PR c++/95193
+// { dg-do compile { target c++17 } }
+
+struct X {
+ void foo() const {
+ auto GL1 = [*this](auto a) {
+ };
+
+ GL1("abc");
+ }
+};