Just to add a small note: As soon as your int values overflow, your program engenders undefined behavior. It just so happens that "overflow by wrapping around to negative integers" is the behavior that often occurs here. https://en.cppreference.com/w/cpp/language/ub#Signed_overflow
Often, code will wrap back to negative when there isn't optimization enabled, but as soon as you enable optimization... the compiler has a field day.
1 2 3
int foo(int x) {
return x+1 > x; // either true or UB due to signed overflow
}