Previously we were doing 1 << S. "1" is an int, so this doesn't work
when S >= 32.
This patch also adds some static_asserts to these functions to ensure
that we don't hit UB by shifting left too much.
Differential D22441
Fix isShiftedInt and isShiftedUint for widths > 32. jlebar on Jul 16 2016, 3:17 PM. Authored by
Details Previously we were doing 1 << S. "1" is an int, so this doesn't work This patch also adds some static_asserts to these functions to ensure
Diff Detail Event TimelineComment Actions This has introduced a compile warning on VS2015 builds: 1> MathExtrasTest.cpp Comment Actions
Ugh. I think MSVC is wrong. isUInt<64> does return N >= 64 || x < (UINT64_C(1)<<(N)); Which should be safe because of short-circuit evaluation. I guess we can specialize the isUInt<N> template. :-/ Can we file a bug on msvc? Comment Actions RKSimon, can you try D22472? I'm going to close this revision again, otherwise it's confusing to have an open revision after the patch has landed. Let's take further discussion into that thread, if that's OK. Comment Actions Thanks its fixed the shift count warning but now has an operator precedence warning. If you're after a buildbot to check things, llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast will help. It doesn't treat warnings as errors so the build stays green and you need to drill down into the build stdio: |