Closed
Description
Zig Version
0.13.0
Steps to Reproduce and Observed Output
Compile the program below using zig cc
:
//test.c
int main() {
int arr[5] = {1, 2, 3, 4, 5};
int* dest = arr+6-(6*1);
(void)dest;
return 0;
}
Then run it and it shows the message: Illegal instruction (core dumped)
. After investigating I found out that this happens because an array bound check. When I compile the same code using clang -fsanitize=array-bounds test.c
, I get the error: test.c:3:18: runtime error: index 6 out of bounds for type 'int[5]' SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior test.c:3:18 in
. I'm linking the verbose message of zig cc for detailed information.
Expected Output
test.c:3:18: runtime error: index 6 out of bounds for type 'int[5]' SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior test.c:3:18 in