From 4e4120a27ac1e2abd4a5309aefcc4ba0dac45784 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Wed, 4 Jul 2018 15:31:56 +0100 Subject: 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/include/std/bit | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libstdc++-v3/include/std/bit') diff --git a/libstdc++-v3/include/std/bit b/libstdc++-v3/include/std/bit index ace8895..a23f2ba 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 -- cgit v1.1