On Wed, 17 Dec 2025 at 06:55, Jakub Jelinek <[email protected]> wrote:
>
> On Tue, Dec 16, 2025 at 02:52:27PM -0500, Nathan Myers wrote:
> > PR libstdc++/119739
> > * include/bits/random.tcc: Add generate_canonical impl for C++26.
> > *
> > testsuite/26_numerics/random/uniform_real_distribution/operators/64351.cc:
> > Adapt test for both pre- and post- C++26.
> > *
> > testsuite/26_numerics/random/uniform_real_distribution/operators/gencanon.cc:
> > Test for float and double from 32-bit RNG, including 1.0 do-over.
>
> This breaks some tests.
> On x86_64-linux
> FAIL: 17_intro/headers/c++1998/all_pedantic_errors.cc -std=gnu++17 (test for
> excess errors)
> Excess errors:
> /home/jakub/src/gcc/obj20/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/random.tcc:3681:
> error: ISO C++ does not support '__int128' for 'type name' [-Wpedantic]
> /home/jakub/src/gcc/obj20/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/random.tcc:3698:
> error: ISO C++ does not support '__int128' for 'type name' [-Wpedantic]
> for which I'm attaching patch below,
> FAIL: std/ranges/adaptors/93978.cc -std=gnu++20 (test for excess errors)
> Excess errors:
> /home/jakub/src/gcc/obj20/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/random.tcc:3664:
> warning: typedef 'using _Rng = decltype (_Urbg::max())' locally defined but
> not used [-Wunused-local-typedefs]
> FAIL: std/ranges/adaptors/93978.cc -std=gnu++26 (test for excess errors)
> Excess errors:
> /home/jakub/src/gcc/obj20/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/random.tcc:3664:
> warning: typedef 'using _Rng = decltype (_Urbg::max())' locally defined but
> not used [-Wunused-local-typedefs]
> where that
> using _Rng = decltype(_Urbg::max());
> indeed looks unused and it is unclear if you want to use
> it somewhere or remove,
I think it can be removed. I don't think the next line intended to use
numeric_limits<_Rng> instead of numeric_limits<_RealT>, so the _Rng
type is not needed.
> FAIL: 26_numerics/random/pr60037-neg.cc -std=gnu++17 (test for errors, line
> 3480)
> FAIL: 26_numerics/random/pr60037-neg.cc -std=gnu++17 (test for excess errors)
> Excess errors:
> /home/jakub/src/gcc/obj20/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/random.tcc:3653:
> error: static assertion failed: template argument must be floating point
> and on i686-linux tons of further FAILs like:
> FAIL: 26_numerics/random/fisher_f_distribution/operators/serialize.cc
> -std=gnu++17 (test for excess errors)
> Excess errors:
> /home/jakub/src/gcc/obj21/i686-pc-linux-gnu/libstdc++-v3/include/bits/random.tcc:3700:
> error: static assertion failed: irregular RNG with float precision >32
> requires __int128 support
> /home/jakub/src/gcc/obj21/i686-pc-linux-gnu/libstdc++-v3/include/bits/random.tcc:3705:
> warning: no return statement in function returning non-void [-Wreturn-type]
> UNRESOLVED: 26_numerics/random/fisher_f_distribution/operators/serialize.cc
> -std=gnu++17 compilation failed to produce executable
It would be nice if we didn't getting "missing return" diagnostics
after a failed static_assert; clearly it can't fail to return anything
if it doesn't even compile.
> I think it is all of
> FAIL: 20_util/is_function/91371.cc -std=gnu++17 (test for excess errors)
> FAIL: 26_numerics/random/bernoulli_distribution/operators/serialize.cc
> -std=gnu++17 (test for excess errors)
> FAIL: 26_numerics/random/binomial_distribution/114359.cc -std=gnu++17 (test
> for excess errors)
> FAIL: 26_numerics/random/binomial_distribution/operators/serialize.cc
> -std=gnu++17 (test for excess errors)
> FAIL: 26_numerics/random/cauchy_distribution/operators/serialize.cc
> -std=gnu++17 (test for excess errors)
> FAIL: 26_numerics/random/chi_squared_distribution/83833.cc -std=gnu++17
> (test for excess errors)
> FAIL: 26_numerics/random/chi_squared_distribution/operators/serialize.cc
> -std=gnu++17 (test for excess errors)
> FAIL: 26_numerics/random/discrete_distribution/operators/call-default.cc
> -std=gnu++17 (test for excess errors)
> FAIL: 26_numerics/random/discrete_distribution/operators/serialize.cc
> -std=gnu++17 (test for excess errors)
> FAIL: 26_numerics/random/exponential_distribution/operators/serialize.cc
> -std=gnu++17 (test for excess errors)
> FAIL: 26_numerics/random/extreme_value_distribution/operators/serialize.cc
> -std=gnu++17 (test for excess errors)
> FAIL: 26_numerics/random/fisher_f_distribution/operators/serialize.cc
> -std=gnu++17 (test for excess errors)
> FAIL: 26_numerics/random/gamma_distribution/operators/serialize.cc
> -std=gnu++17 (test for excess errors)
> FAIL: 26_numerics/random/geometric_distribution/operators/serialize.cc
> -std=gnu++17 (test for excess errors)
> FAIL: 26_numerics/random/lognormal_distribution/operators/serialize.cc
> -std=gnu++17 (test for excess errors)
> FAIL: 26_numerics/random/negative_binomial_distribution/operators/58302.cc
> -std=gnu++17 (test for excess errors)
> FAIL:
> 26_numerics/random/negative_binomial_distribution/operators/serialize.cc
> -std=gnu++17 (test for excess errors)
> FAIL: 26_numerics/random/normal_distribution/operators/equal.cc -std=gnu++17
> (test for excess errors)
> FAIL: 26_numerics/random/normal_distribution/operators/serialize.cc
> -std=gnu++17 (test for excess errors)
> FAIL:
> 26_numerics/random/piecewise_constant_distribution/operators/call-default.cc
> -std=gnu++17 (test for excess errors)
> FAIL:
> 26_numerics/random/piecewise_constant_distribution/operators/serialize.cc
> -std=gnu++17 (test for excess errors)
> FAIL:
> 26_numerics/random/piecewise_linear_distribution/operators/call-default.cc
> -std=gnu++17 (test for excess errors)
> FAIL: 26_numerics/random/piecewise_linear_distribution/operators/serialize.cc
> -std=gnu++17 (test for excess errors)
> FAIL: 26_numerics/random/poisson_distribution/operators/serialize.cc
> -std=gnu++17 (test for excess errors)
> FAIL: 26_numerics/random/pr60037-neg.cc -std=gnu++17 (test for errors, line
> 3480)
> FAIL: 26_numerics/random/pr60037-neg.cc -std=gnu++17 (test for excess errors)
> FAIL: 26_numerics/random/student_t_distribution/operators/serialize.cc
> -std=gnu++17 (test for excess errors)
> FAIL: 26_numerics/random/uniform_real_distribution/operators/64351.cc
> -std=gnu++17 execution test
> FAIL: 26_numerics/random/uniform_real_distribution/operators/gencanon.cc
> -std=gnu++17 execution test
> FAIL: 26_numerics/random/uniform_real_distribution/operators/serialize.cc
> -std=gnu++17 (test for excess errors)
> FAIL: 26_numerics/random/weibull_distribution/operators/serialize.cc
> -std=gnu++17 (test for excess errors)
> FAIL: ext/random/arcsine_distribution/operators/serialize.cc -std=gnu++17
> (test for excess errors)
> FAIL: ext/random/beta_distribution/operators/serialize.cc -std=gnu++17 (test
> for excess errors)
> FAIL: ext/random/hoyt_distribution/operators/serialize.cc -std=gnu++17 (test
> for excess errors)
> FAIL: ext/random/hypergeometric_distribution/operators/serialize.cc
> -std=gnu++17 (test for excess errors)
> FAIL: ext/random/k_distribution/operators/serialize.cc -std=gnu++17 (test
> for excess errors)
> FAIL: ext/random/logistic_distribution/operators/serialize.cc -std=gnu++17
> (test for excess errors)
> FAIL: ext/random/nakagami_distribution/operators/serialize.cc -std=gnu++17
> (test for excess errors)
> FAIL: ext/random/normal_mv_distribution/operators/serialize.cc -std=gnu++17
> (test for excess errors)
> FAIL: ext/random/pareto_distribution/operators/serialize.cc -std=gnu++17
> (test for excess errors)
> FAIL: ext/random/rice_distribution/operators/serialize.cc -std=gnu++17 (test
> for excess errors)
> FAIL: ext/random/triangular_distribution/operators/serialize.cc -std=gnu++17
> (test for excess errors)
> FAIL: ext/random/uniform_inside_sphere_distribution/operators/generate.cc
> -std=gnu++17 (test for excess errors)
> FAIL: ext/random/uniform_inside_sphere_distribution/operators/serialize.cc
> -std=gnu++17 (test for excess errors)
> FAIL: ext/random/uniform_on_sphere_distribution/operators/generate.cc
> -std=gnu++17 (test for excess errors)
> FAIL: ext/random/uniform_on_sphere_distribution/operators/serialize.cc
> -std=gnu++17 (test for excess errors)
> FAIL: ext/random/von_mises_distribution/operators/serialize.cc -std=gnu++17
> (test for excess errors)
> Because we don't have unsigned _BitInt(128) in C++ right now, I'm afraid you
> want some unsigned __int128 like class for #ifndef __SIZEOF_INT128__ which
> will handle all the operations you need on a pair of unsigned long long.
We already have this in <bits/random.h>
#if __SIZEOF_INT128__ > __SIZEOF_LONG_LONG__
template<int __s>
struct _Select_uint_least_t<__s, 1>
{ __extension__ using type = unsigned __int128; };
#elif __has_builtin(__builtin_add_overflow) \
&& __has_builtin(__builtin_sub_overflow) \
&& defined __UINT64_TYPE__
template<int __s>
struct _Select_uint_least_t<__s, 1>
{
// This is NOT a general-purpose 128-bit integer type.
// It only supports (type(a) * x + c) % m as needed by __mod.
struct type
{
and we already need a more general 128-bit type to support
std::philox_engine<uint64_t> on 32-bit targets.
I think 1nfocalypse at Bay Libre was going to look at extending the
type above for philox, but I've been thinking about doing it myself
too.
> Note, some time ago I was working on an int128 and uint128 for libgcobol,
> https://gcc.gnu.org/bugzilla/attachment.cgi?id=61011 is the latest patch
> (part of https://gcc.gnu.org/PR119595), it probably has far more than
> you actually need and not the libstdc++-v3 formatting.
Thanks, that's useful.