2 ms·
> the compiler cannot assume that adding one will eventually turn negative and then later on reach 0 Signed overflow is undefined behavior, so it is allowed to
by TheCoelacanth 5y ago
> the compiler cannot assume that adding one will eventually turn negative and then later on reach 0
Signed overflow is undefined behavior, so it is allowed to assume that. It's also allowed to assume anything else that it wants to.
Once you cause a signed overflow, all guarantees are out the window and the compiler can do anything it wants to.