Overflowing an integer is undefined behavior. Then the compiler is allowed to assume you are not going to overflow integers and optimize accordingly.
I was doing some delicate bit-fiddling code and got a surprise, that if you put in a file this
#include <stdint.h>
void consume(bool);
extern long maxInt;