From 4e4120a27ac1e2abd4a5309aefcc4ba0dac45784 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Wed, 4 Jul 2018 15:31:56 +0100 Subject: [PATCH] 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 --- libstdc++-v3/ChangeLog | 5 +++++ libstdc++-v3/include/std/bit | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) 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 -- 2.30.2