Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes esl_varint test failure on OS/X with a specific LLVM/clang vers…
…ion. esl_varint_utest started failing in Google varint tests. Unclear what changed on my machine; I'm sure it was passing before. Developed a small test case around floor_log2k(). I only see the problem on Apple LLVM/clang 9.1.0 (clang-902.0.30), using -O or greater optimization but not -g. Doesn't happen with LLVM/clang 9.0.0 (clang-900.0.39.2); nor with clang -g, clang -g -O, or clang alone; nor with gcc on ody, or with gcc-8 on OS/X. I'm attributing it to a probable Apple compiler bug in optimizing right bit shifts on nonnegative signed integers. Right bit shifts on *negative* signed ints are undefined, ok, but are supposed to be fine on nonnegative signed ints, and mine are guaranteed nonnegative here. The compiler is out there, so we have to live with it. Decided not to trust right shifts of signed ints at all. Replaced floor_log2k() and floor_log2() with implementations that don't use rightshifting. Replaced all other `>>` ops on signed ints in esl_varint too. [xref 0323-llvm-bug]
- Loading branch information