forked from higan-emu/higan
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix critical undefined bit-shift length operation
Natural/Integer<T>.bit() (BitRange) was shifting by whatever type the source was to match the target bit length. But this breaks when the target type is u64/s64 and the source type is u32/s32 or smaller. Shifting by >=32 becomes undefined behavior. We have to cast the input source to the target type first, so that the source<<shift result is valid. This is safe here regardless of source's signedness, because it's only used in =, &=, ^=, |= operations.
- Loading branch information
1 parent
029a437
commit 9febc7d
Showing
1 changed file
with
16 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters