3 ms·
> Most compilers assume UB "can't happen" and just remove the offending code altogether. To be clearer: UBs (specifically the assumption that they don’t happen
by masklinn 5y ago
> Most compilers assume UB "can't happen" and just remove the offending code altogether.
To be clearer: UBs (specifically the assumption that they don’t happen) get translated into constraints (since C’s type system is extremely weak UBs are a very valuable source of such constraints to optimising compilers), those constraints are then propagated (forwards, and backwards, and upwards due to inlining) and any path for which the constraint does not hold can be considered dead.