[clang] [Clang] [Sema] Always rebuild `this` if captured by value in a lambda with a dependent explicit object parameter (PR #154276)
Corentin Jabot via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 19 00:35:29 PDT 2025
================
@@ -264,3 +264,28 @@ void test() {
// CHECK: call void @_ZNH5P27971C1cERKS0_
// CHECK: call void @_ZN5P27971C1cEi
}
+
+// This used to crash because we weren’t instantiating a dependent 'this'.
+namespace GH154054 {
+struct S {
+ int x;
+ auto byval() {
+ return [*this](this auto) { return this->x; };
+ }
+};
+
+void main() {
+ S s{ 42 };
+
+ if ( s.byval()() != 42)
+ __builtin_abort();
----------------
cor3ntin wrote:
This doesn't do much, maybe we want check lines to verify we refer to the correct object?
https://github.com/llvm/llvm-project/pull/154276
More information about the cfe-commits
mailing list