[clang] [clang][bytecode] Fix __builtin_is_within_lifetime in initializers (PR #147480)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 8 07:06:38 PDT 2025
================
@@ -2208,15 +2208,27 @@ static bool interp__builtin_is_within_lifetime(InterpState &S, CodePtr OpPC,
if (Ptr.isOnePastEnd())
return Error(1);
- bool Result = true;
+ bool Result = Ptr.getLifetime() != Lifetime::Ended;
if (!Ptr.isActive()) {
Result = false;
} else {
if (!CheckLive(S, OpPC, Ptr, AK_Read))
return false;
if (!CheckMutable(S, OpPC, Ptr))
return false;
+ if (!CheckDummy(S, OpPC, Ptr, AK_Read))
+ return false;
+ }
+
+ // Check if we're currently running an initializer.
+ for (InterpFrame *Frame = S.Current; Frame; Frame = Frame->Caller) {
+ if (const Function *F = Frame->getFunction();
+ F && F->isConstructor() && Frame->getThis().block() == Ptr.block()) {
+ return Error(2);
+ }
----------------
tbaederr wrote:
Forgot to push that, thanks!
https://github.com/llvm/llvm-project/pull/147480
More information about the cfe-commits
mailing list