This expression can be found in the Example in §8.5.4/7 in the Standard (N3797)
unsigned int ui1 = {-1}; // error: narrows
Given §8.5.4/7 and its 4th bullet point:
A narrowing conversion is an implicit conversion:
- from an integer type or unscoped enumeration type to an integer type that cannot represent all the values of the original type, except where the source is a constant expression whose value after integral promotions will fit into the target type.
I would say there's no narrowing here, as -1 is a constant expression, whose value after integral promotion fits into an unsigned int.
See also §4.5/1 about Integral Promotion:
A prvalue of an integer type other than bool, char16_t, char32_t, or wchar_t whose integer conversion rank (4.13) is less than the rank of int can be converted to a prvalue of type int if int can represent all the values of the source type; otherwise, the source prvalue can be converted to a prvalue of type unsigned int.
From 4.13 we have that the rank of -1 (an int) is equal to the rank of an unsigned int, and so it can be converted to an unsigned int.
Edit
Unfortunately Jerry Coffin removed his answer from this thread. I believe he was on the right track, if we accept the fact that the current reading of the 4th bullet point in §8.5.4/7 is wrong, after this change in the Standard.
unisgned integer
cannot represent all the values of asigned integer
, specifically; it cannot represent a negative value. – Afint
, and as such, it's not promoted to anything. – Irritable