================ @@ -1561,16 +1577,21 @@ llvm::Value *CodeGenFunction::EmitCXXNewExpr(const CXXNewExpr *E) { // 1. Build a call to the allocation function. FunctionDecl *allocator = E->getOperatorNew(); - // If there is a brace-initializer, cannot allocate fewer elements than inits. + // If there is a brace-initializer or C++20 parenthesized initializer, cannot + // allocate fewer elements than inits. unsigned minElements = 0; if (E->isArray() && E->hasInitializer()) { - const InitListExpr *ILE = dyn_cast<InitListExpr>(E->getInitializer()); - if (ILE && ILE->isStringLiteralInit()) + const Expr *Init = E->getInitializer(); + const InitListExpr *ILE = dyn_cast<InitListExpr>(Init); + const CXXParenListInitExpr *CPLIE = dyn_cast<CXXParenListInitExpr>(Init); + if ((ILE && ILE->isStringLiteralInit()) || isa<StringLiteral>(Init)) { ---------------- MitalAshok wrote:
You forget to `IgnoreParenImpCasts` or check for `ObjCEncodeExpr`. Currently: ```c++ // seg fault int n = 0; char* p = new char[n](("a")); // throws bad_alloc (expected) int n = 0; char* p = new char[n](("a")); ``` https://github.com/llvm/llvm-project/pull/76976 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits