bitwise: don't allow full rotation

This commit is contained in:
Danny Robson 2019-04-26 10:27:22 +10:00
parent 1ca47626aa
commit 0144018992

View File

@ -24,7 +24,7 @@ namespace cruft {
constexpr T
rotatel [[gnu::pure]] (const T value, std::size_t magnitude)
{
CHECK_LE (magnitude, sizeof (value) * 8);
CHECK_LT (magnitude, sizeof (value) * 8u);
return (value << magnitude) | (value >> (sizeof (value) * 8 - magnitude));
}
@ -38,7 +38,7 @@ namespace cruft {
constexpr T
rotater [[gnu::pure]] (const T value, std::size_t magnitude)
{
CHECK_LE (magnitude, sizeof (value) * 8);
CHECK_LT (magnitude, sizeof (value) * 8);
return (value >> magnitude) | (value << (sizeof (value) * 8 - magnitude));
}