https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/127788
None >From dff6bd91600617d7b631be09ff7c06c5a2fd5786 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbae...@redhat.com> Date: Wed, 19 Feb 2025 12:46:49 +0100 Subject: [PATCH] [clang][bytecode] Fix allocating primitive arrays of unknown bound --- clang/lib/AST/ByteCode/Compiler.cpp | 3 ++- clang/test/AST/ByteCode/new-delete.cpp | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index 503c58a67adeb..a35aa9471a73d 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -3397,7 +3397,8 @@ bool Compiler<Emitter>::VisitCXXNewExpr(const CXXNewExpr *E) { CtorFunc = getFunction(CE->getConstructor()); if (!CtorFunc) return false; - } + } else if (!DynamicInit) + DynamicInit = Init; LabelTy EndLabel = this->getLabel(); LabelTy StartLabel = this->getLabel(); diff --git a/clang/test/AST/ByteCode/new-delete.cpp b/clang/test/AST/ByteCode/new-delete.cpp index 7e5f6ab8815ea..5be1bb944c18c 100644 --- a/clang/test/AST/ByteCode/new-delete.cpp +++ b/clang/test/AST/ByteCode/new-delete.cpp @@ -907,6 +907,12 @@ namespace IncompleteArray { return c; } static_assert(test4() == 12); + + + constexpr char *f(int n) { + return new char[n](); + } + static_assert((delete[] f(2), true)); } namespace NonConstexprArrayCtor { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits