You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Possible undefined behavior in new ll2string() implementation. #1940
if long long svalue == MIN_INT64 then -svalue yields UB (signed overflow - even if it will probably be 0)
#include <stdint.h>
int main() {
uint64_t X = -INT64_MIN;
return 0;
}
Result of compilation:
$ gcc ub.c
ub.c: In function ‘main’:
ub.c:4:16: warning: integer overflow in expression [-Woverflow]
uint64_t X = -INT64_MIN;
since value in your code is signed, -value is signed as well. If value == INT64_MIN then -value overflows. The C standard says[1] that a signed overflow is UB. AFAICT the fact that by chance the compiler is doing the right thing is irrelevant.
Activity
Fix undefined behavior in ll2string().
antirez commentedon Aug 15, 2014
@CAFxX and @mattsta, the problem was actually there indeed, thanks, would love to double check with you if the fix I propose seems appropriate.
CAFxX commentedon Aug 18, 2014
@antirez from a quick look it looks correct; I will check better ASAP
Fix undefined behavior in ll2string().
Fix undefined behavior in ll2string().
CAFxX commentedon Sep 4, 2014
I finally had time to review it; LGTM.
antirez commentedon Sep 4, 2014
Thanks @CAFxX, the fix was already shipped with 2.8.14, I also tested it with clang undefined behavior detector just to be sure.
Update RedisTimeSeries module to v8.9.80
Update RedisTimeSeries module to v8.9.80 (#15336)