https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125548
--- Comment #1 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Tomasz Kaminski <[email protected]>: https://gcc.gnu.org/g:86a93aaef14c1597f531a826f0004c6a86e9fdd4 commit r17-2392-g86a93aaef14c1597f531a826f0004c6a86e9fdd4 Author: Tomasz KamiÅski <[email protected]> Date: Mon Jun 1 15:31:11 2026 +0200 libstdc++: Fix weight computation for piecewise_linear_distribution(nw, xmin, xmax, fw) constructor [PR125548] Compute kth weight using __fw(_M_int[k]) as required by standard, instead of __fw(_M_int[k] + __delta), i.e. __fw(_M_int[k + 1]). For __nw == 1, this was already corrected by r17-509-g7bed7d9276c11b. In both cases, previous behavior can be restored by defining _GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS. PR libstdc++/125548 libstdc++-v3/ChangeLog: * doc/html/manual/using_macros.html: (_GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS): Mention PR125548 * doc/xml/manual/using.xml: Regenerate * include/bits/random.tcc (piecewise_linear_distribution::param_type::param_type(size_t, _RealType, ...)): Update weight computation. * testsuite/26_numerics/random/piecewise_linear_distribution/operators/serialize2.cc: Updated expected values. * testsuite/26_numerics/random/piecewise_linear_distribution/cons/pr125548.cc: New test. * testsuite/26_numerics/random/piecewise_linear_distribution/cons/pr125548_fallback.cc: Run pr125548.cc with _GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS. Reviewed-by: Jonathan Wakely <[email protected]> Signed-off-by: Tomasz KamiÅski <[email protected]>
