David Marchand <[email protected]> writes: > We recently started to get random failures on the common_autotest ut with > clang on Ubuntu 16.04.6. > > Example: https://travis-ci.com/DPDK/dpdk/jobs/263177424 > > Wrong rte_log2_u64(0) val 0, expected ffffffff > Test Failed > > The ut passes 0 to log2() to get an expected value. > > Quoting log2 / log(3) manual: > If x is zero, then a pole error occurs, and the functions return > -HUGE_VAL, -HUGE_VALF, or -HUGE_VALL, respectively. > > rte_log2_uXX helpers handle 0 as a special value and return 0. > Let's have dedicated tests for this case. > > Fixes: 05c4345ef5c2 ("test: add unit test for integer log2 function") > Cc: [email protected] > > Signed-off-by: David Marchand <[email protected]> > ---
Acked-by: Aaron Conole <[email protected]> Somethings that concern me: 1. A log2(0) should probably be an undetermined value, but this effectively makes log2(0) == log2(1) so that if anyone uses these for some mathematical work, it will have an exceptional behavior. I know it's documented from a programmer perspective, but I am all for documenting the mathematical side effect as well. 2. Why hasn't this been complaining for so long? Or has it and we just haven't noticed? Were some compiler flags changed recently? (maybe -funsafe-math was always set or something?) -Aaron

