When an integer overflows, the most significant bits that don't fit are discarded, so memory corruption can never occur (however, there's no overflow here - when reading a value with cin and an overflow would occur, the largest possible value is used instead, as you noticed).