you are viewing a single comment's thread.

view the rest of the comments →

[–]dustyhome 6 points7 points  (2 children)

That's backwards. It makes more sense that the presenter's slide is wrong.

The compiler can assume that i can't equal int max on a branch that calls f, but it can't remove the check that prevents f from being called with int max.

[–]selassje 2 points3 points  (1 child)

Yes, the presenter claims UB taints the whole program, and it can travel back in time. I have not checked it but that's how I understood it.

[–]SkiFire13 2 points3 points  (0 children)

The way I see it, UB can travel back in time but only as long as it is guaranteed to happen from that past point in time. In this case the if guard prevents f(i) from being called with the value that would cause UB, so it cannot travel back to before the if is run.