On Tue, Oct 27, 2020 at 09:48:54AM +0000, Peter Chen wrote:
If you compile the code:
unsigned int k = 0x80 << 24 + 0x81;
It will report build warning: warning: left shift count >= width of type [-Wshift-count-overflow]
That's a separate issue. I believe (but haven't checked) that the << operator has lower precedence than +, so the compiler interprets the expression as:
unsigned int k = 0x80 << (24 + 0x81);
and it's pretty obvious why this causes an error. Instead, try compiling:
unsigned int k = (0x80 << 24) + 0x81;
You may get an error message about signed-integer overflow, but not about shift-count overflow.
Alan Stern