K&R states that the right operand must be non-negative.
"The shift operators << and >> perform left and right shifts of their
left operand by the number of bit positions given by the right operand,
which must be non-negative"
unsigned int n = 10;
n <<= -2;
MSVC7 accepts this above code as valid and compiles it.
Should this be allowed, it seems like it could lead to subtle bugs?
rcn
"The shift operators << and >> perform left and right shifts of their
left operand by the number of bit positions given by the right operand,
which must be non-negative"
unsigned int n = 10;
n <<= -2;
MSVC7 accepts this above code as valid and compiles it.
Should this be allowed, it seems like it could lead to subtle bugs?
rcn
Comment