This code shows no errors when compiled with -Wall -Wextra -Wpedantic -Werror:
#include <cstdio>
int main()
{
int arr[10] = {1,2,3};
printf("%d\n", *(arr + 10));
}
But the indexing operation is optimized away nonetheless (-O3 -Wall -Wextra -Wpedantic -Werror):
main:
push rax
lea rdi, [rip + .L.str]
xor eax, eax
call printf@PLT
xor eax, eax
pop rcx
ret
.L.str:
.asciz "%d\n"