Skip to content

Commit 46a55d0

Browse files
committed
fix some overflow UB
1 parent 3416efd commit 46a55d0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

bitbtest.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ static const unsigned int high_flip[56] = {
215215
#define bbFlips_Right_low(pos, mask) \
216216
contig = right_contiguous[(opp_bits_low >> (pos + 1)) & mask]; \
217217
fl = right_flip[contig] << (pos + 1); \
218-
t = -(int)(my_bits_low & fl) >> 31; \
218+
t = ((int)(-(unsigned int)(my_bits_low & fl))) >> 31u; \
219219
my_bits_low |= fl & t; \
220220
flipped = contig & t
221221
#endif
@@ -775,7 +775,7 @@ static const unsigned int high_flip[56] = {
775775
t &= (opp_bits_high >> (pos + vec * 3 - 32)); \
776776
contig += t; \
777777
fl = lsb_mask[contig] & mask; \
778-
t = -(int)(my_bits_high & fl) >> 31; \
778+
t = ((int)(-(unsigned int)(my_bits_high & fl))) >> 31u; \
779779
my_bits_high |= fl & t; \
780780
flipped += contig & t; \
781781
}

0 commit comments

Comments
 (0)