3 ms·
> , after all, the compiler needs to check for UB to generate code. No the compiler does not check for UB to generate code. A lot of UB (runtime out of bounds,
by dureuill 3y ago
> , after all, the compiler needs to check for UB to generate code.
No the compiler does not check for UB to generate code. A lot of UB (runtime out of bounds, use after free) are very difficult to detect statically (at least without specialized annotations).
The compiler applies transformations to the code that are valid (in the sense that they produce an equivalent program) only in the absence of UB.
So if the input program contains UB, the transformed program produced by the compiler may or may not be valid