HomeFreeBSD

Fix undefined behavior: (1 << 31) is not defined as 1 is an int and this
rS258780Unpublished

Unpublished Commit ยท Learn More

No further details are available.

Description

Fix undefined behavior: (1 << 31) is not defined as 1 is an int and this
shifts into the sign bit. Instead use (1U << 31) which gets the
expected result.

This fix is not ideal as it assumes a 32 bit int, but does fix the issue
for most cases.

A similar change was made in OpenBSD.

Discussed with: -arch, rdivacky
Reviewed by: cperciva

Details

Provenance
eadlerAuthored on
Parents
rS258779: Similar to the (1 << 31) case it is not defined to do (2 << 30).
Branches
Unknown
Tags
Unknown

Event Timeline