[all-commits] [llvm/llvm-project] 87db72: [clang] Fix crash constant-evaluating the construc...
Akash Manna via All-commits
all-commits at lists.llvm.org
Thu Oct 1 11:58:17 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 87db7285dac15df66fcc702136cd6106264935ae
https://github.com/llvm/llvm-project/commit/87db7285dac15df66fcc702136cd6106264935ae
Author: Akash Manna <akash.manna.mymail at gmail.com>
Date: 2026-10-02 (Fri, 02 Oct 2026)
Changed paths:
M clang/docs/ReleaseNotes.md
M clang/lib/AST/ByteCode/Compiler.cpp
M clang/lib/AST/ByteCode/InterpHelpers.h
M clang/lib/AST/ExprConstant.cpp
M clang/test/AST/ByteCode/dynalloc-limits.cpp
Log Message:
-----------
[clang] Fix crash constant-evaluating the construction of huge arrays (#226899)
Fixes #173728
The constant evaluator runs on ordinary code all the time (range checks
for `-W` warnings, `isEvaluatable` in codegen), and it
default-constructs an array by building one `APValue` per element. The
element count got truncated to `unsigned` first and nothing checked its
size, so a local like `struct T {} s[0xFFFFFFFF][0]` ran it out of
memory; with the issue's reproducer, where the count wraps to 2^64 - 4,
an assertions build hits the "bounds check failed" assertion in
`adjustIndex` first. Copying such an array, e.g. into a lambda capture,
had the same problem. This goes back to at least Clang 3.4. The bytecode
interpreter has its own version: it emits code for every element, so a
constructor with a member like `T a[0xFFFFFFFF]` runs it out of memory
too.
Array default construction and `ArrayInitLoopExpr` now go through the
existing `CheckArraySize` guard, the same one `new` already uses, so
evaluation just gives up once the count is too large or over the
`-fconstexpr-steps` limit. The bytecode compiler makes the same decision
up front and emits only the failing check instead of code for the
elements. With `-g` in an assertions build, the reduced reproducer then
trips the IR verifier (`!DISubrange(count: -4)`); that is a separate
problem with arrays of 2^63 or more elements and is not part of this
change I think.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list