[clang] [clang][CodeGen] Fix assertion failure for new T[SIZE_MAX] with array cookie (PR #232570)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 16 21:53:20 PDT 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- clang/test/CodeGenCXX/new-array-cookie-overflow.cpp clang/lib/CodeGen/CGExprCXX.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp
index b55bb578d..a1b3e2827 100644
--- a/clang/lib/CodeGen/CGExprCXX.cpp
+++ b/clang/lib/CodeGen/CGExprCXX.cpp
@@ -1793,8 +1793,8 @@ llvm::Value *CodeGenFunction::EmitCXXNewExpr(const CXXNewExpr *E) {
// differ, but on overflow the allocation size is all-ones, which can
// coincide with the size without the cookie.
assert(allocSize == llvm::Constant::getAllOnesValue(SizeTy) ||
- ((allocSize == allocSizeWithoutCookie) ==
- CalculateCookiePadding(*this, E).isZero()));
+ ((allocSize == allocSizeWithoutCookie) ==
+ CalculateCookiePadding(*this, E).isZero()));
if (allocSize != allocSizeWithoutCookie) {
assert(E->isArray());
allocation = CGM.getCXXABI().InitializeArrayCookie(
``````````
</details>
https://github.com/llvm/llvm-project/pull/232570
More information about the cfe-commits
mailing list