std::string s{ "aa" };
s.length() - 3; // == very large number
From memory, C's integer promotion rules (idk about C++) produce a type wide enough to fit the result of the calculation and favour unsigned types (for the extra bit of width). But 3
is of type int
(right?). So why is the result of type unsigned
instead of int
or long
? unsigned
is certainly not wide enough to capture the result of the expression!