c3lang / c3c

Compiler for the C3 language
https://c3-lang.org
GNU Lesser General Public License v3.0
2.68k stars 163 forks source link

Incomplete bounds checking when slicing by length #1191

Closed cbuttner closed 4 months ago

cbuttner commented 5 months ago

Slicing by length does not seem to do a complete bounds check.

int[4] array;
int[] slice = &array;

// These are all caught to be out of bounds
// int[] slice1 = slice[2..5];
// int[] slice2 = slice[6..];
// int[] slice3 = slice[0..9];
// int[] slice4 = slice[5:10];
// These ones aren't
int[] slice5 = slice[:10];
int[] slice6 = slice[2:10];
lerno commented 5 months ago

This should now be fixed in dev and master.

cbuttner commented 4 months ago

Looks good. This will help to catch some bugs.

lerno commented 4 months ago

Thank you for reporting it!