Can branches with undefined behavior be assumed unreachable and optimized as dead code?

Does the existence of such a statement in a given program mean that the whole program is undefined or that behavior only becomes undefined once control flow hits this statement? Neither. The first condition is too strong and the second is too weak. Object access are sometimes sequenced, but the standard describes the behavior of … Read more

Is pointer comparison undefined or unspecified behavior in C++?

Note that pointer subtraction and pointer comparison are different operations with different rules. C++14 5.6/6, on subtracting pointers: Unless both pointers point to elements of the same array object or one past the last element of the array object, the behavior is undefined. C++14 5.9/3-4: Comparing pointers to objects is defined as follows: If two … Read more