[clang] [analyzer] Improve handling of &array[size] in ArrayBound (PR #214540)
Balázs Benics via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 6 12:49:44 PDT 2026
steakhal wrote:
claude told me about an allegedly interesting case for this PR, but I'll leave it here.
```c++
int TenElements[10];
int *disjointRangeSet(int i) {
if (i > 10) return 0;
if (i == 0) return 0;
if (i == 1) return 0;
if (i == 2) return 0;
if (i == 3) return 0;
if (i == 4) return 0;
if (i == 5) return 0;
if (i == 6) return 0;
if (i == 7) return 0;
if (i == 8) return 0;
if (i == 9) return 0;
// State now: i <= 10 && i not in {0..9} => i in [MIN,-1] U {10}.
return &TenElements[i]; // now warns; previously it didn't
}
```
The PR looks good to me btw.
https://github.com/llvm/llvm-project/pull/214540
More information about the cfe-commits
mailing list