From: Jonathan Wakely Date: Wed, 4 Jul 2018 14:31:56 +0000 (+0100) Subject: Fix std::__rotl and std::__rotr X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4e4120a27ac1e2abd4a5309aefcc4ba0dac45784;p=gcc.git Fix std::__rotl and std::__rotr 2018-07-04 Jonathan Wakely Jakub Jelinek * include/std/bit (__rotl, __rotr): Fix for non-power of two sizes. Co-Authored-By: Jakub Jelinek From-SVN: r262414 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index fa92b4bb489..b1747e82cb8 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,8 @@ +2018-07-04 Jonathan Wakely + Jakub Jelinek + + * include/std/bit (__rotl, __rotr): Fix for non-power of two sizes. + 2018-07-04 Jonathan Wakely PR libstdc++/86398 diff --git a/libstdc++-v3/include/std/bit b/libstdc++-v3/include/std/bit index ace88954030..a23f2ba60d1 100644 --- a/libstdc++-v3/include/std/bit +++ b/libstdc++-v3/include/std/bit @@ -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 @@ -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