ac_int GCC sanitizer error on negative left shift
Opened this issue · 0 comments
maubri commented
GCC's UB sanitizer complains about a negative left shift which is in fact UB. The following patch solves the issue:
--- a/include/ac_int.h
+++ b/include/ac_int.h
@@ -1028,7 +1028,7 @@ namespace ac_private {
}
}
template<> inline void iv_shift_l<1,1>(const int *op1, unsigned op2, int *r) {
- r[0] = op2 < 32 ? op1[0] << op2 : 0;
+ r[0] = op2 < 32 ? static_cast<unsigned int>(op1[0]) << op2 : 0u;
}
template<> inline void iv_shift_l<2,1>(const int *op1, unsigned op2, int *r) {
Ulong vop1 =
Note other specialization of iv_shift_l do implement the missing cast which suggests this was overlooked only in this particular one.