Page MenuHomePhabricator

Avoid the use of abs64 in timedata
ClosedPublic

Authored by PiRK on Nov 11 2021, 07:50.

Details

Reviewers
majcosta
Group Reviewers
Restricted Project
Commits
rABCf61fd4290412: Avoid the use of abs64 in timedata
Summary

Issue core#20135:

When extending the test/fuzz/integer fuzzer I noticed the following UBSan warning when fuzzing abs64(...):

runtime error: negation of -9223372036854775808 cannot be represented in type 'int64_t' (aka 'long'); cast to an unsigned type to negate this value to itself

Typically abs(I n) type functions are not defined when n == std::numeric_limits<I>::min() so it could be argued that this is expected, but perhaps the function could be rewritten in a way which guarantees that it gives the same behaviour across systems (instead of UB).

This is a backport of core#20141

Test Plan

ninja all check-all