Is this undefined behavior?
unsigned int size = 0;
size -= 1;
Is this undefined behavior?
unsigned int size = 0;
size -= 1;
Unsigned integers have well-defined behaviour for all arithmetic operations; specifically, they implement "artithmetic modulo 2N", where N is the number of value bits in the type. So -1
is in fact 2N − 1.