]> granicus.if.org Git - python/commit
pytime: add _PyTime_check_mul_overflow() macro to avoid undefined behaviour
authorVictor Stinner <victor.stinner@gmail.com>
Thu, 10 Sep 2015 13:55:07 +0000 (15:55 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Thu, 10 Sep 2015 13:55:07 +0000 (15:55 +0200)
commitc60542b12bdf11487b959bbb304f4ea194be6a19
tree8348fc4667e247b4f382dfc263dcb9b8f559c1f0
parentff0ed3e71cb828103cf21442231686f1b348479b
pytime: add _PyTime_check_mul_overflow() macro to avoid undefined behaviour

Overflow test in test_FromSecondsObject() fails on FreeBSD 10.0 buildbot which
uses clang. clang implements more aggressive optimization which gives
different result than GCC on undefined behaviours.

Check if a multiplication will overflow, instead of checking if a
multiplicatin had overflowed, to avoid undefined behaviour.

Add also debug information if the test on overflow fails.
Lib/test/test_time.py
Python/pytime.c