Hi,

I noticed a few cases in OpenBSD where the expression (1 << 31) is used.

However this produces undefined behavior as '1' is of type int.  (see
6.4.4p5: The type of an unmarked integer constant is the first of the
following list in which its value can be represented: int, long int,
long long int).  The shift of 31 is illegal (see 6.5.7p4) if the size
of an int is 32.  The correct fix here is to use 1U as the literal
instead.

A listing of all cases where I found '1 << 31' can be found here:
http://people.freebsd.org/~eadler/files/o/1..31.txt  Note, I did not
make an effort to remove correct examples.

-- 
Eitan Adler

Reply via email to