Skip to content

Incorrect ArrayOutofBounds behavior #535

@AndrewAday

Description

@AndrewAday
int test[0];

repeat(5) test << 1;

for (test.size() => int i; true; i++) {
    i => test[i];
    <<< test[i] >>>;
}

Outputs:

❯ ./chuck a.ck
5 :(int)
6 :(int)
7 :(int)
[chuck]:(EXCEPTION) ArrayOutofBounds: on line[6] in shred[id=1:a.ck] index[8]

E.g. for an array of size 5, allows writing and reading up until the idx 8.
For an array of size 9, allows writing and reading up until the idx 16.
Seems like the bounds checking is based on the array capacity (which grows by a power of 2 upon resize), and not the actual in-code specified size.

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions