Fix std::__rotl and std::__rotr

2018-07-04  Jonathan Wakely  <jwakely@redhat.com>
	    Jakub Jelinek  <jakub@redhat.com>

	* include/std/bit (__rotl, __rotr): Fix for non-power of two sizes.

Co-Authored-By: Jakub Jelinek <jakub@redhat.com>

From-SVN: r262414
This commit is contained in:
Jonathan Wakely 2018-07-04 15:31:56 +01:00 committed by Jonathan Wakely
parent 04f8c98c51
commit 4e4120a27a
2 changed files with 7 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2018-07-04 Jonathan Wakely <jwakely@redhat.com>
Jakub Jelinek <jakub@redhat.com>
* include/std/bit (__rotl, __rotr): Fix for non-power of two sizes.
2018-07-04 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/86398

View File

@ -46,7 +46,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
constexpr auto _Nd = numeric_limits<_Tp>::digits;
const unsigned __sN = __s % _Nd;
return (__x << __sN) | (__x >> ((-__sN) % _Nd));
return (__x << __sN) | (__x >> ((_Nd - __sN) % _Nd));
}
template<typename _Tp>
@ -55,7 +55,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
constexpr auto _Nd = numeric_limits<_Tp>::digits;
const unsigned __sN = __s % _Nd;
return (__x >> __sN) | (__x << ((-__sN) % _Nd));
return (__x >> __sN) | (__x << ((_Nd - __sN) % _Nd));
}
template<typename _Tp>