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
+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
{
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>
{
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>