diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-22 15:06:13 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-22 15:21:11 +0000 |
| commit | fa83b7df5a0711bf5f4a5162cc33b0a4123a53c7 (patch) | |
| tree | dcfd24756256fcef21c43f19aa6e914455435806 /lib/CodeGen/ArrayOutput.cc | |
| parent | 353c38e23108856daa2c5d0e86443ac5136dcaa7 (diff) | |
fix(arrays): reject inverted bounds and check array allocation
Constant inverted bounds are a compile error and other bounds are checked
at run time. Allocation sizes use overflow-checked arithmetic, and a NULL
malloc (including the BYVAL copy) reports that the array is too large.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Diffstat (limited to 'lib/CodeGen/ArrayOutput.cc')
| -rw-r--r-- | lib/CodeGen/ArrayOutput.cc | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/CodeGen/ArrayOutput.cc b/lib/CodeGen/ArrayOutput.cc index 9306823..99b4a91 100644 --- a/lib/CodeGen/ArrayOutput.cc +++ b/lib/CodeGen/ArrayOutput.cc @@ -62,6 +62,8 @@ void ArrayHandler::emitPrintLoop(const std::string &Name, } Function *TheFunction = Builder->GetInsertBlock()->getParent(); + // Do-while shape: safe because every array has at least one element per + // dimension (inverted bounds are rejected at declaration). BasicBlock *LoopBB = BasicBlock::Create(*TheContext, "arr_loop", TheFunction); BasicBlock *AfterBB = BasicBlock::Create(*TheContext, "arr_after", TheFunction); |
