Check for obvious array bounds overflow
- Dominant language
- Rust
- Stars
- 1.7k
- Forks
- 218
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 6
Description
### What is wrong?
The analyzer should check for obvious overflow of array bounds. For example:
```
x: u8[4]
x[10] = 0
```
### How can it be fixed
The analyzer's `ExpressionAttributes` struct could contain an optional `static_value` field to propagate literal and staticly-knowable values of expressions upward to parent analysis checks. Eg
```
a: u8[10]
x: u8 = 10
y: u8 = x + 2
a[y] // easy for the analyzer to know that y == 12
// and for the subscript check to emit an out-of-bounds error
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by locating the analyzer's ExpressionAttributes struct and the subscript check described in the issue. Trace how literal and statically knowable expression values are currently analyzed, then define tests for direct and propagated out-of-bounds array indexes. Done means the analyzer reports the obvious overflow cases shown in the examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100