Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a few instances of undefined behavior (that I'm not yet aware of any concrete consequences of) in left shift expressions. Roughly, it's undefined behavior to shift a `1` into the sign bit of a signed type. Operands in bit shift expressions undergo integer promotions, but not the usual arithmetic conversions. Notably, the second operand can't promote the first operand to unsigned. Shifting `1` rather than `1U` can lead to shifting a `1` into the sign bit, causing undefined behavior. Relatedly, the integer promotions on a 32-bit platform will usually promote `uint16_t` to a signed `int`, leading to undefined behavior in left shift expressions.
- Loading branch information