Hard
An out-of-bounds array write and the code after it
arr has four elements. Compiled with -O2, what happens to the write on the line marked (1) and to everything after it?
main.cpp
#include <cstdio>
void run(bool trigger) {
int arr[4] = {1, 2, 3, 4};
if (trigger) {
arr[10] = 99; // (1) out-of-bounds write, UB
printf("after write\n"); // (2)
}
printf("done\n");
}8 of 44 in Compilers