> So even if your UB code isn't called, the simple fact it exists may make some seemingly-unrelated code behave wrongly.
This is fortunately not true. If it were, it would make runtime checks pointless. Consider this code
free(ptr)
already_freed = true;
if (!alread_freed) {
free(ptr)
}
The second free would be undefined behavior, but since it doesn't run the snippet is fine.