Kaydet (Commit) 8bde421c authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Work around cid#1328486

...claiming that "right shifting v by more than 15 bits always yields zero,"
apparently diagnosing an instanatiation of the template for T = unsigned short.

Change-Id: I7c210ff17e4aef8f0e703cc30518f3420e67e7c1
üst 1b3f81bd
......@@ -214,10 +214,11 @@ template< typename T > inline T shiftRight( T v, int shift )
static_assert(
std::is_unsigned<T>::value,
"must be unsigned for promotedBits and the below ': 0' to be correct");
auto const promotedBits = std::numeric_limits<decltype(+T())>::digits;
using Promoted = decltype(+T());
auto const promotedBits = std::numeric_limits<Promoted>::digits;
return shift >= 0
? shift < promotedBits ? v >> shift : 0
: -shift < promotedBits ? v << (-shift) : 0;
? shift < promotedBits ? Promoted(v) >> shift : 0
: -shift < promotedBits ? Promoted(v) << (-shift) : 0;
}
} // namespace basebmp
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment