4 ms·
That is an obvious misreading. Assume you have an unsigned char array r[] declared with 100 elements and the compiler encounters the following line of code: r
by torstenvl 3y ago
That is an obvious misreading.
Assume you have an unsigned char array r[] declared with 100 elements and the compiler encounters the following line of code:
r[200] = 0xff;
"ignoring the situation completely with unpredictable results" means translating that to the appropriate object code without bounds checking and no guarantees are made about whether that's a segfault or what your environment does.
"assum[ing] that the situation simply won't happen" means eliding the code entirely.
The first is required by the standard. The second is prohibited by the standard.
There is no section of any version of the standard that permits compilers to assume that anything which might be UB or predicated on UB is dead code.
Compilers must either ignore the fact that it's UB, or behave in a documented implementation-defined manner, or stop translation.