Skip to content

[clang][bytecode] Variadic ctors also start lifetime#201113

Merged
tbaederr merged 1 commit into
llvm:mainfrom
tbaederr:variadic-ctor
Jun 2, 2026
Merged

[clang][bytecode] Variadic ctors also start lifetime#201113
tbaederr merged 1 commit into
llvm:mainfrom
tbaederr:variadic-ctor

Conversation

@tbaederr

@tbaederr tbaederr commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

This is the same thing we do in the non-variadic Call().

@llvmorg-github-actions llvmorg-github-actions Bot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:bytecode Issues for the clang bytecode constexpr interpreter labels Jun 2, 2026
This is the same thing we do in the non-variadic `Call()`.
@llvmorg-github-actions

Copy link
Copy Markdown

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

Changes

This is the same thing we do in the non-variadic Call().


Full diff: https://github.com/llvm/llvm-project/pull/201113.diff

2 Files Affected:

  • (modified) clang/lib/AST/ByteCode/Interp.cpp (+2-1)
  • (modified) clang/test/AST/ByteCode/records.cpp (+13)
diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp
index 6bcebf3ee892b..0ea6de1742175 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -1747,7 +1747,8 @@ bool CallVar(InterpState &S, CodePtr OpPC, const Function *Func,
     if (!(S.Current->getFunction() &&
           S.Current->getFunction()->isLambdaStaticInvoker() &&
           Func->isLambdaCallOperator())) {
-      if (!CheckInvoke(S, OpPC, ThisPtr))
+      if (!CheckInvoke(S, OpPC, ThisPtr,
+                       Func->isConstructor() || Func->isDestructor()))
         return false;
     }
 
diff --git a/clang/test/AST/ByteCode/records.cpp b/clang/test/AST/ByteCode/records.cpp
index a9b8ac6b10bcb..b792b56563b2f 100644
--- a/clang/test/AST/ByteCode/records.cpp
+++ b/clang/test/AST/ByteCode/records.cpp
@@ -2031,3 +2031,16 @@ namespace StaticMemberRedecl {
   const int S::m = 10;
   static_assert(getM() == 10, "");
 }
+
+namespace VariadicCtorStartsLifetime {
+  struct S {
+    constexpr S(int, ...) {}
+  };
+  class C {
+  public:
+    S s;
+    constexpr C() : s(1,1) {}
+  };
+  /// Used to not start the lifetime of 's'.
+  constexpr C c;
+}

@tbaederr tbaederr merged commit 16853f6 into llvm:main Jun 2, 2026
10 checks passed
yingopq pushed a commit to yingopq/llvm-project that referenced this pull request Jun 5, 2026
This is the same thing we do in the non-variadic `Call()`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:bytecode Issues for the clang bytecode constexpr interpreter clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant