Commit 4e4120a2 by Jonathan Wakely Committed by Jonathan Wakely

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
parent 04f8c98c
2018-07-04 Jonathan Wakely <jwakely@redhat.com> 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 PR libstdc++/86398
* include/std/type_traits (is_trivially_constructible): Check * include/std/type_traits (is_trivially_constructible): Check
......
...@@ -46,7 +46,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -46,7 +46,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ {
constexpr auto _Nd = numeric_limits<_Tp>::digits; constexpr auto _Nd = numeric_limits<_Tp>::digits;
const unsigned __sN = __s % _Nd; const unsigned __sN = __s % _Nd;
return (__x << __sN) | (__x >> ((-__sN) % _Nd)); return (__x << __sN) | (__x >> ((_Nd - __sN) % _Nd));
} }
template<typename _Tp> template<typename _Tp>
...@@ -55,7 +55,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -55,7 +55,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ {
constexpr auto _Nd = numeric_limits<_Tp>::digits; constexpr auto _Nd = numeric_limits<_Tp>::digits;
const unsigned __sN = __s % _Nd; const unsigned __sN = __s % _Nd;
return (__x >> __sN) | (__x << ((-__sN) % _Nd)); return (__x >> __sN) | (__x << ((_Nd - __sN) % _Nd));
} }
template<typename _Tp> template<typename _Tp>
......
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