You have a signed int, so the numbers are in two additions. Here's what's going on
00..01 = 1 00..10 = 2 [...] 01..00 = 1073741824 10..00 = -2147483648 // Highest bit to one means -01..11 - 1 = -(2^31) 00..00 = 0
You cannot contact INT_MAX, at best you will have 2^30 .
As stated in the comments, the C ++ standard does not use 2 add-ons, so this code may behave differently on other machines.
source share