Your analysis in this question is right. Because the value is in the range of int
and is converted to int
as part of the initialization (note: the same would happen for assignment), everything works as intended.
As for the hidden part of your question you didn't ask, since it keeps getting closed as a duplicate, this does not mean you can define INT_MIN
as -2147483648
. The magic is in the =
(as assignment operator or a token in the initialization construct). In contexts where it's not being used, there are all sorts of ways that -2147483648
having type long
or long long
rather than int
breaks semantic requirements on INT_MIN
. For example:
(INT_MIN < 0U) == 0
(because both operands are promoted to unsigned
), but
(-2147483648 < 0U) == 1
(because both operands are promoted to long
or long long
).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…