https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118841
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> --- (In reply to Jonathan Wakely from comment #2) > Maybe like this: > > --- a/libstdc++-v3/include/bits/random.tcc > +++ b/libstdc++-v3/include/bits/random.tcc > @@ -3351,12 +3351,17 @@ namespace __detail > static_assert(std::is_floating_point<_RealType>::value, > "template argument must be a floating point type"); > > + using _MaxRealType > + = __conditional_t<(std::numeric_limits<_RealType>::digits > + <= std::numeric_limits<double>::digits), > + double, long double>; > const size_t __b > = > std::min(static_cast<size_t>(std::numeric_limits<_RealType>::digits), > __bits); > - const long double __r = static_cast<long double>(__urng.max()) > - - static_cast<long double>(__urng.min()) + 1.0L; > - const size_t __log2r = std::log(__r) / std::log(2.0L); > + const _MaxRealType __r = static_cast<_MaxRealType>(__urng.max()) > + - static_cast<_MaxRealType>(__urng.min()) > + + 1.0L; This one would need to be _MaxRealType(1.0) or so. Otherwise it is still evaluated in long double.