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