Date: Wed, 13 Nov 2013 16:26:08 -0700
> I have not seen the examples, but is it not the case that casting to unsigned
> before the shifts would have created defined behavior?
Yes, all of the undefined behaviors due to LHS of shifts would go away
with appropriate casts. I imagine that people just don't realize these
are necessary.
The bulk of the UBs were due to promotion of unsigned char to int. A
minority were due to variables that were declared as signed types in the
first place -- not a good idea, as you remarked earlier.
John
> before the shifts would have created defined behavior?
Yes, all of the undefined behaviors due to LHS of shifts would go away
with appropriate casts. I imagine that people just don't realize these
are necessary.
The bulk of the UBs were due to promotion of unsigned char to int. A
minority were due to variables that were declared as signed types in the
first place -- not a good idea, as you remarked earlier.
John
Received on 2013-11-14 00:26:26