3 ms·
> Why let the program behave buggy when llvm can see that undefined behaviour will occur? It's not quite that easy. Because compilers these days have a large n
by lomnakkus 11y ago
> Why let the program behave buggy when llvm can see that undefined behaviour will occur?
It's not quite that easy. Because compilers these days have a large number of phases/optimization passes it can be prohibitively difficult to trace back from the location of a potential UB to what might/does trigger it (in the source). So what compilers do is ASSUME that no UB can occur, hence there's no need to generate a check for "b=0".
You can run clang with -fsanitize=undefined, though, and get runtime-checks for many UBs. It'll cost you runtime performance, though.