[clang] [clang][constexpr] Evaluate parenthesized array new with the allocated bound (PR #228675)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 3 21:39:32 PDT 2026


tbaederr wrote:

You need to fix the bytecode interpreter too:
```diff
diff --git i/clang/lib/AST/ByteCode/Compiler.cpp w/clang/lib/AST/ByteCode/Compiler.cpp
index 313687f53816..58e68de845c9 100644
--- i/clang/lib/AST/ByteCode/Compiler.cpp
+++ w/clang/lib/AST/ByteCode/Compiler.cpp
@@ -4384,6 +4384,10 @@ bool Compiler<Emitter>::VisitCXXNewExpr(const CXXNewExpr *E) {
             DynamicInit = ILE->getArrayFiller();
           else if (StaticInitElems > 0 && isa<StringLiteral>(ILE->getInit(0)))
             ElemT = classifyPrim(CAT->getElementType());
+        } else if (const auto *PLI = dyn_cast<CXXParenListInitExpr>(Init)) {
+          DynamicInit = PLI->getArrayFiller();
+          if (StaticInitElems > 0 && isa<StringLiteral>(PLI->getInitExprs()[0]))
+            ElemT = classifyPrim(CAT->getElementType());
         }
       }
```

https://github.com/llvm/llvm-project/pull/228675


More information about the cfe-commits mailing list