Issue |
148381
|
Summary |
capturing this pointer in lambda coroutines
|
Labels |
new issue
|
Assignees |
|
Reporter |
Comrade88
|
found the following behavior in clang version 17: when capturing the pointer this in a lambda coroutine, the value of the pointer is stored directly in the coroutine state field (__coro_frame). as a result, accessing class members through captured this doesn't cause a use-after-free error if the lifetime of the object exceeds the lifetime of the coroutine. however, other capture methods consistently lead to the problem described in CP.51.
this behavior persists up to the latest clang version 20. meanwhile, g++ behaves differently: the captured this pointer is stored in a lambda structure whose address is saved in the coroutine state, leading to use-after-free issues upon destruction of the temporary lambda object.
questions:
- what reasoning underlies the implementation of capturing this in lambda coroutines in clang?
- are there provisions in the C++ Standard mandating such behavior?
- is there any plan to modify this logic in future versions of clang, or should we consider it a unique feature of the compiler?
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs