On Mon, 21 Sept 2026 at 15:34, Tomasz Kamiński <[email protected]> wrote: > > This patch introduces _GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS that > replaces a separate _GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS (value 0) > and _GLIBCXX_USE_RESULT_TYPE_FOR_PIECEWISE_DENSITIES (value 2). > > This better reflects their behavior, as they were not orthogonal previously > as defining _GLIBCXX_USE_RESULT_TYPE_FOR_PIECEWISE_DENSITIES hand no effect > if _GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS was defined. > > libstdc++-v3/ChangeLog: > > PR libstdc++/82749 > PR libstdc++/125548 > * doc/html/manual/status.html: Regenerate. > * doc/html/manual/using_macros.html: Regenrate. > * doc/xml/manual/using.xml > (_GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS) > (_GLIBCXX_USE_RESULT_TYPE_FOR_PIECEWISE_DENSITIES): Replace with... > (_GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS): Add entry. > * include/bits/c++config (_GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS) > [__cplusplus >= 201103L]: Define to the value 1 if not already > defined. > * include/bits/random.h > (__detail::__piecewise_distributions_storage): > (__detail::__piecewise_distributions_storage_t): Adjust to depend > on _GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS value. > (piecewise_constant_distribution::_CalcType) > (piecewise_linear_distribution::_CalcType) > (piecewise_constant_distribution::param_type::densities) > (piecewise_linear_distribution::param_type::densities): > Check for non-zero value of _GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS > instead of defintion of _GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS and > reorder branches. > * include/bits/random.tcc > (piecewise_constant_distribution::param_type::param_type) > (piecewise_constant_distribution::param_type::param_type): Likewise. > * > testsuite/26_numerics/random/piecewise_constant_distribution/operators/accessors.cc: > Replace checks for _GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS > _GLIBCXX_USE_RESULT_TYPE_FOR_PIECEWISE_DENSITIES defintions > with checks of _GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS values. > * > testsuite/26_numerics/random/piecewise_linear_distribution/operators/accessors.cc: > Likewise. > * > testsuite/26_numerics/random/piecewise_linear_distribution/cons/pr125548.cc: > Likewise. > * > testsuite/26_numerics/random/piecewise_constant_distribution/operators/accessors_fallback.cc: > Replace -D_GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS with > -D_GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS=0. > * > testsuite/26_numerics/random/piecewise_linear_distribution/operators/accessors_fallback.cc: > Likewise. > * > testsuite/26_numerics/random/piecewise_linear_distribution/cons/pr125548_fallback.cc: > Likewise. > * > testsuite/26_numerics/random/piecewise_constant_distribution/cons/input_type_fallback_neg.cc: > Likewise. > * > testsuite/26_numerics/random/piecewise_linear_distribution/cons/input_type_fallback_neg.cc: > Likewise. > * > testsuite/26_numerics/random/piecewise_constant_distribution/operators/accessors_exact.cc: > Replace -D_GLIBCXX_USE_RESULT_TYPE_FOR_PIECEWISE_DENSITIES with > -D_GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS=2. > * > testsuite/26_numerics/random/piecewise_linear_distribution/operators/accessors_exact.cc: > Likewise. > --- > v2: > * moved _GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS to c++config > * applied suggested wording fixes > > OK for trunk?
OK with the typo in the summary fixed as discussed offlist - thanks > > .../doc/html/manual/using_macros.html | 35 +++++++------ > libstdc++-v3/doc/xml/manual/using.xml | 38 +++++++------- > libstdc++-v3/include/bits/c++config | 4 ++ > libstdc++-v3/include/bits/random.h | 52 +++++++++---------- > libstdc++-v3/include/bits/random.tcc | 18 +++---- > .../cons/input_type_fallback_neg.cc | 2 +- > .../operators/accessors.cc | 22 ++++---- > .../operators/accessors_exact.cc | 2 +- > .../operators/accessors_fallback.cc | 2 +- > .../cons/input_type_fallback_neg.cc | 2 +- > .../cons/pr125548.cc | 10 ++-- > .../cons/pr125548_fallback.cc | 2 +- > .../operators/accessors.cc | 24 ++++----- > .../operators/accessors_exact.cc | 2 +- > .../operators/accessors_fallback.cc | 2 +- > 15 files changed, 111 insertions(+), 106 deletions(-) > > diff --git a/libstdc++-v3/doc/html/manual/using_macros.html > b/libstdc++-v3/doc/html/manual/using_macros.html > index 6cb467471c8..2f5824ef407 100644 > --- a/libstdc++-v3/doc/html/manual/using_macros.html > +++ b/libstdc++-v3/doc/html/manual/using_macros.html > @@ -156,25 +156,26 @@ > <code class="option">-fexec-charset=UTF-8</code> so might give > incorrect results > if called from a source file that uses a non-Unicode encoding, > especially for format strings using non-ASCII fill characters. > - </p></dd><dt><span class="term"><code > class="code">_GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS</code></span></dt><dd><p> > - Undefined by default. > - When defined, the behavior of specializations of > + </p></dd><dt><span class="term"><code > class="code">_GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS</code></span></dt><dd><p> > + Defined to the value <code class="literal">1</code>, if not provided. > + ABI-changing when defined to the value <code class="literal">2</code>. > + > + When defined to a non-zero value, > <code class="code">piecewise_constant_distribution</code> and > - <code class="code">piecewise_linear_distribution</code> > - is restored to their state prior the implementation > - of <a class="link" > href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82749" target="_top"> > - PR82749</a> (<a class="link" > href="https://cplusplus.github.io/LWG/lwg-defects.html#1439" target="_top"> > - LWG1439</a>), <a class="link" > href="https://cplusplus.github.io/LWG/lwg-defects.html#4052" target="_top"> > + <code class="code">piecewise_linear_distribution</code> incorporates > corrections > + from <a class="link" > href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82749" target="_top"> > + PR82749</a> (<a class="link" > href="https://cplusplus.github.io/LWG/lwg-defects.html#1439" > target="_top">LWG1439</a>), <a class="link" > href="https://cplusplus.github.io/LWG/lwg-defects.html#4052" target="_top"> > LWG4052</a>, and <a class="link" > href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125548" target="_top"> > - PR125548</a>) in GCC 17. > - </p></dd><dt><span class="term"><code > class="code">_GLIBCXX_USE_RESULT_TYPE_FOR_PIECEWISE_DENSITIES</code></span></dt><dd><p> > - Undefined by default. ABI-changing. > - When defined, specializations of > - <code class="code">piecewise_constant_distribution</code> and > - <code class="code">piecewise_linear_distribution</code> with a > - <code class="code">result_type</code> of either <code > class="code">float</code> or > - <code class="code">long double</code> will manage their internal > state using > - <code class="code">result_type</code> values (instead of <code > class="code">double</code>). > + PR125548</a> in GCC 17. > + </p><p> > + When defined to the value <code class="literal">0</code>, their > behavior > + is restored to their state prior changes in GCC 17. > + </p><p> > + When defined to the value <code class="literal">2</code>, > specializations of > + beforementioned distributions with a <code > class="code">result_type</code> of > + either <code class="code">float</code> or <code class="code">long > double</code> will manage > + their internal state using <code class="code">result_type</code> > values (instead > + of <code class="code">double</code>). > This is required for standard conformance, but is incompatible with > the default implementation of those class templates. > </p></dd></dl></div></div><div class="navfooter"><hr /><table > width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a > accesskey="p" href="using_headers.html">Prev</a> </td><td width="20%" > align="center"><a accesskey="u" href="using.html">Up</a></td><td width="40%" > align="right"> <a accesskey="n" > href="using_dual_abi.html">Next</a></td></tr><tr><td width="40%" align="left" > valign="top">Headers </td><td width="20%" align="center"><a accesskey="h" > href="../index.html">Home</a></td><td width="40%" align="right" valign="top"> > Dual ABI</td></tr></table></div></body></html> > \ No newline at end of file > diff --git a/libstdc++-v3/doc/xml/manual/using.xml > b/libstdc++-v3/doc/xml/manual/using.xml > index da710be408f..9cb93ec76d5 100644 > --- a/libstdc++-v3/doc/xml/manual/using.xml > +++ b/libstdc++-v3/doc/xml/manual/using.xml > @@ -1379,35 +1379,35 @@ g++ -Winvalid-pch -I. -include stdc++.h -H -g -O2 > hello.cc -o test.exe > especially for format strings using non-ASCII fill characters. > </para> > </listitem></varlistentry> > - > <varlistentry><term><code>_GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS</code></term> > + > <varlistentry><term><code>_GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS</code></term> > <listitem> > <para> > - Undefined by default. > - When defined, the behavior of specializations of > + Defined to the value <literal>1</literal>, if not provided. > + ABI-changing when defined to the value <literal>2</literal>. > + > + When defined to a non-zero value, > <code>piecewise_constant_distribution</code> and > - <code>piecewise_linear_distribution</code> > - is restored to their state prior the implementation > - of <link xmlns:xlink="http://www.w3.org/1999/xlink" > + <code>piecewise_linear_distribution</code> incorporates corrections > + from <link xmlns:xlink="http://www.w3.org/1999/xlink" > xlink:href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82749"> > PR82749</link> (<link xmlns:xlink="http://www.w3.org/1999/xlink" > - xlink:href="https://cplusplus.github.io/LWG/lwg-defects.html#1439"> > - LWG1439</link>), <link xmlns:xlink="http://www.w3.org/1999/xlink" > + xlink:href="https://cplusplus.github.io/LWG/lwg-defects.html#1439" > + >LWG1439</link>), <link xmlns:xlink="http://www.w3.org/1999/xlink" > xlink:href="https://cplusplus.github.io/LWG/lwg-defects.html#4052"> > LWG4052</link>, and <link xmlns:xlink="http://www.w3.org/1999/xlink" > xlink:href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125548"> > - PR125548</link>) in GCC 17. > + PR125548</link> in GCC 17. > </para> > - </listitem></varlistentry> > - > <varlistentry><term><code>_GLIBCXX_USE_RESULT_TYPE_FOR_PIECEWISE_DENSITIES</code></term> > - <listitem> > <para> > - Undefined by default. ABI-changing. > - When defined, specializations of > - <code>piecewise_constant_distribution</code> and > - <code>piecewise_linear_distribution</code> with a > - <code>result_type</code> of either <code>float</code> or > - <code>long double</code> will manage their internal state using > - <code>result_type</code> values (instead of <code>double</code>). > + When defined to the value <literal>0</literal>, their behavior > + is restored to their state prior changes in GCC 17. > + </para> > + <para> > + When defined to the value <literal>2</literal>, specializations of > + beforementioned distributions with a <code>result_type</code> of > + either <code>float</code> or <code>long double</code> will manage > + their internal state using <code>result_type</code> values (instead > + of <code>double</code>). > This is required for standard conformance, but is incompatible with > the default implementation of those class templates. > </para> > diff --git a/libstdc++-v3/include/bits/c++config > b/libstdc++-v3/include/bits/c++config > index 60456a48681..0c2407ccd07 100644 > --- a/libstdc++-v3/include/bits/c++config > +++ b/libstdc++-v3/include/bits/c++config > @@ -969,6 +969,10 @@ namespace __gnu_cxx > #endif // __has_include > #endif // C++17 > > +#if __cplusplus >= 201103L && > !defined(_GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS) > +# define _GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS 1 > +#endif > + > #pragma GCC diagnostic pop > > // End of prewritten config; the settings discovered at configure time > follow. > diff --git a/libstdc++-v3/include/bits/random.h > b/libstdc++-v3/include/bits/random.h > index 1a2900e2b9d..16e149b469d 100644 > --- a/libstdc++-v3/include/bits/random.h > +++ b/libstdc++-v3/include/bits/random.h > @@ -6466,10 +6466,10 @@ _GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2) > > namespace __detail > { > -#if defined(_GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS) > +#if _GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS == 0 > template<typename _Tp> > using __piecewise_distributions_storage_t = double; > -#elif defined(_GLIBCXX_USE_RESULT_TYPE_FOR_PIECEWISE_DENSITIES) > +#elif _GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS == 2 > template<typename _Tp> > using __piecewise_distributions_storage_t = _Tp; > #else > @@ -6525,10 +6525,10 @@ _GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2) > > using _StorageType > = __detail::__piecewise_distributions_storage_t<_RealType>; > -#ifdef _GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS > - using _CalcType = double; > -#else > +#if _GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS > using _CalcType = _RealType; > +#else > + using _CalcType = double; > #endif > > public: > @@ -6574,11 +6574,7 @@ _GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2) > return _M_int; > } > > -#ifdef _GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS > - std::vector<double> > - densities() const > - { return _M_den.empty() ? std::vector<double>(1, 1.0) : _M_den; } > -#else > +#if _GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS > // _GLIBCXX_RESOLVE_LIB_DEFECTS > // 1439. Return from densities() functions? > [[__gnu__::__abi_tag__("__rt")]] > @@ -6595,6 +6591,10 @@ _GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2) > return std::vector<_RealType>(_M_den.begin(), _M_den.end()); > #pragma GCC diagnostic pop > } > +#else > + std::vector<double> > + densities() const > + { return _M_den.empty() ? std::vector<double>(1, 1.0) : _M_den; } > #endif > > friend bool > @@ -6670,13 +6670,13 @@ _GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2) > /** > * @brief Returns a vector of the probability densities. > */ > -#ifdef _GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS > - std::vector<double> > +#if _GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS > + [[__gnu__::__always_inline__]] > + std::vector<result_type> > densities() const > { return _M_param.densities(); } > #else > - [[__gnu__::__always_inline__]] > - std::vector<result_type> > + std::vector<double> > densities() const > { return _M_param.densities(); } > #endif > @@ -6840,10 +6840,10 @@ _GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2) > > using _StorageType > = __detail::__piecewise_distributions_storage_t<_RealType>; > -#ifdef _GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS > - using _CalcType = double; > -#else > +#if _GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS > using _CalcType = _RealType; > +#else > + using _CalcType = double; > #endif > > public: > @@ -6889,11 +6889,7 @@ _GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2) > return _M_int; > } > > -#ifdef _GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS > - std::vector<double> > - densities() const > - { return _M_den.empty() ? std::vector<double>(2, 1.0) : _M_den; } > -#else > +#if _GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS > // _GLIBCXX_RESOLVE_LIB_DEFECTS > // 1439. Return from densities() functions? > [[__gnu__::__abi_tag__("__rt")]] > @@ -6910,6 +6906,10 @@ _GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2) > return std::vector<_RealType>(_M_den.begin(), _M_den.end()); > #pragma GCC diagnostic pop > } > +#else > + std::vector<double> > + densities() const > + { return _M_den.empty() ? std::vector<double>(2, 1.0) : _M_den; } > #endif > > friend bool > @@ -6987,13 +6987,13 @@ _GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2) > * @brief Return a vector of the probability densities of the > * distribution. > */ > -#ifdef _GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS > - std::vector<double> > +#if _GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS > + [[__gnu__::__always_inline__]] > + std::vector<result_type> > densities() const > { return _M_param.densities(); } > #else > - [[__gnu__::__always_inline__]] > - std::vector<result_type> > + std::vector<double> > densities() const > { return _M_param.densities(); } > #endif > diff --git a/libstdc++-v3/include/bits/random.tcc > b/libstdc++-v3/include/bits/random.tcc > index b2b18e66f5f..ab4bb09dc3d 100644 > --- a/libstdc++-v3/include/bits/random.tcc > +++ b/libstdc++-v3/include/bits/random.tcc > @@ -3065,10 +3065,10 @@ namespace __detail > // 4052. Bogus requirements for piecewise_linear_distribution > auto __cfw = [&__fw](_RealType __n, _RealType __p) > { > -#ifdef _GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS > - return __fw(0.5 * (__n + __p)); > -#else > +#if _GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS > return _RealType(__fw(_RealType(0.5) * (__n + __p))); > +#else > + return __fw(0.5 * (__n + __p)); > #endif > }; > > @@ -3098,10 +3098,10 @@ namespace __detail > const _RealType __delta = (__xmax - __xmin) / __n; > auto __cfw = [&__fw, __delta](_RealType __v) > { > -#ifdef _GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS > - return __fw(__v + 0.5 * __delta); > -#else > +#if _GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS > return _RealType(__fw(__v + _RealType(0.5) * __delta)); > +#else > + return __fw(__v + 0.5 * __delta); > #endif > }; > > @@ -3380,12 +3380,12 @@ namespace __detail > const _RealType __delta = (__xmax - __xmin) / __n; > const auto __cfw = [&] (_RealType __v) > { > -#ifdef _GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS > - return __fw(__v + __delta); > -#else > +#if _GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS > // _GLIBCXX_RESOLVE_LIB_DEFECTS > // 4052. Bogus requirements for piecewise_linear_distribution > return _RealType(__fw(__v)); > +#else > + return __fw(__v + __delta); > #endif > }; > > diff --git > a/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/cons/input_type_fallback_neg.cc > > b/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/cons/input_type_fallback_neg.cc > index 6fb04ef7655..3dfba49d7f9 100644 > --- > a/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/cons/input_type_fallback_neg.cc > +++ > b/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/cons/input_type_fallback_neg.cc > @@ -1,4 +1,4 @@ > -// { dg-options "-D_GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS" } > +// { dg-options "-D_GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS=0" } > // { dg-do compile { target c++11 } } > // { dg-require-cstdint "" } > > diff --git > a/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/operators/accessors.cc > > b/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/operators/accessors.cc > index b31b028dc27..f8034ef08a0 100644 > --- > a/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/operators/accessors.cc > +++ > b/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/operators/accessors.cc > @@ -19,10 +19,10 @@ test_exact() > VERIFY( interval[0] == RealType(0.0) ); > VERIFY( interval[5] == RealType(5.0) ); > > -#ifdef _GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS > - const std::vector<double>& density = u.densities(); > -#else > +#if _GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS > const std::vector<RealType>& density = u.densities(); > +#else > + const std::vector<double>& density = u.densities(); > #endif > > VERIFY( density.size() == 5 ); > @@ -38,9 +38,9 @@ void > test_precision_depended() > { > constexpr bool preserved > -#ifdef _GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS > +#if _GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS == 0 > = sizeof(InputType) <= sizeof(double); > -#elifdef _GLIBCXX_USE_RESULT_TYPE_FOR_PIECEWISE_DENSITIES > +#elif _GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS == 2 > = sizeof(InputType) <= sizeof(DistType); > #else > // input is converted to DistType and stored in double > @@ -61,10 +61,10 @@ test_precision_depended() > VERIFY( interval[0] == DistType(0.0) ); > VERIFY( interval[2] == DistType(1.0) ); > > -#ifdef _GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS > - const std::vector<double>& density = dist.densities(); > -#else > +#if _GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS > const std::vector<DistType>& density = dist.densities(); > +#else > + const std::vector<double>& density = dist.densities(); > #endif > > VERIFY( density.size() == 2 ); > @@ -91,10 +91,10 @@ test_engine_calls() > { > constexpr std::size_t bits = __builtin_popcountg(URBG::max() - > URBG::min()); > constexpr std::size_t calls > -#ifdef _GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS > - = (std::numeric_limits<double>::digits + bits - 1) / bits; > -#else > +#if _GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS > = (std::numeric_limits<RealType>::digits + bits - 1) / bits; > +#else > + = (std::numeric_limits<double>::digits + bits - 1) / bits; > #endif > > struct wrapper : URBG > diff --git > a/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/operators/accessors_exact.cc > > b/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/operators/accessors_exact.cc > index 469ed3fac46..e8e00acab73 100644 > --- > a/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/operators/accessors_exact.cc > +++ > b/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/operators/accessors_exact.cc > @@ -1,4 +1,4 @@ > -// { dg-options "-D_GLIBCXX_USE_RESULT_TYPE_FOR_PIECEWISE_DENSITIES" } > +// { dg-options "-D_GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS=2" } > // { dg-do run { target c++11 } } > // { dg-require-cstdint "" } > #include "accessors.cc" > diff --git > a/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/operators/accessors_fallback.cc > > b/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/operators/accessors_fallback.cc > index 1f7269a879c..b803786368f 100644 > --- > a/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/operators/accessors_fallback.cc > +++ > b/libstdc++-v3/testsuite/26_numerics/random/piecewise_constant_distribution/operators/accessors_fallback.cc > @@ -1,4 +1,4 @@ > -// { dg-options "-D_GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS" } > +// { dg-options "-D_GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS=0" } > // { dg-do run { target c++11 } } > // { dg-require-cstdint "" } > #include "accessors.cc" > diff --git > a/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/cons/input_type_fallback_neg.cc > > b/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/cons/input_type_fallback_neg.cc > index 48ae22b87bb..4bc9ca2704e 100644 > --- > a/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/cons/input_type_fallback_neg.cc > +++ > b/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/cons/input_type_fallback_neg.cc > @@ -1,4 +1,4 @@ > -// { dg-options "-D_GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS" } > +// { dg-options "-D_GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS=0" } > // { dg-do compile { target c++11 } } > // { dg-require-cstdint "" } > > diff --git > a/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/cons/pr125548.cc > > b/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/cons/pr125548.cc > index 2d7ae555eaa..469ce7916c1 100644 > --- > a/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/cons/pr125548.cc > +++ > b/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/cons/pr125548.cc > @@ -4,18 +4,18 @@ > #include <random> > #include <testsuite_hooks.h> > > -void > +void > test_functor(int n) > { > const double step = 1.0/n; > -#ifdef _GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS > - double expected = step; > -#else > +#if _GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS > double expected = 0.0; > +#else > + double expected = step; > #endif > > auto check_val = [&] (double value) mutable { > - VERIFY( value == expected ); > + VERIFY( value == expected ); > expected += step; > return value; > }; > diff --git > a/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/cons/pr125548_fallback.cc > > b/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/cons/pr125548_fallback.cc > index 4b8e6658570..84cb8bad1ad 100644 > --- > a/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/cons/pr125548_fallback.cc > +++ > b/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/cons/pr125548_fallback.cc > @@ -1,4 +1,4 @@ > -// { dg-options "-D_GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS" } > +// { dg-options "-D_GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS=0" } > // { dg-do run { target c++11 } } > // { dg-require-cstdint "" } > #include "pr125548.cc" > diff --git > a/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/operators/accessors.cc > > b/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/operators/accessors.cc > index 5da22fc1011..d94155f0020 100644 > --- > a/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/operators/accessors.cc > +++ > b/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/operators/accessors.cc > @@ -19,10 +19,10 @@ test_exact() > VERIFY( interval[0] == RealType(0.0) ); > VERIFY( interval[5] == RealType(5.0) ); > > -#ifdef _GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS > - const std::vector<double>& density = u.densities(); > -#else > +#if _GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS > const std::vector<RealType>& density = u.densities(); > +#else > + const std::vector<double>& density = u.densities(); > #endif > > VERIFY( density.size() == 6 ); > @@ -39,9 +39,9 @@ void > test_precision_depended() > { > constexpr bool preserved > -#ifdef _GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS > +#if _GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS == 0 > = sizeof(InputType) <= sizeof(double); > -#elifdef _GLIBCXX_USE_RESULT_TYPE_FOR_PIECEWISE_DENSITIES > +#elif _GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS == 2 > = sizeof(InputType) <= sizeof(DistType); > #else > // input is converted to DistType and stored in double > @@ -62,10 +62,10 @@ test_precision_depended() > VERIFY( interval[0] == DistType(0.0) ); > VERIFY( interval[2] == DistType(1.0) ); > > -#ifdef _GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS > - const std::vector<double>& density = dist.densities(); > -#else > +#if _GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS > const std::vector<DistType>& density = dist.densities(); > +#else > + const std::vector<double>& density = dist.densities(); > #endif > > VERIFY( density.size() == 3 ); > @@ -83,7 +83,7 @@ test_precision_depended() > Distribution from_init_list(x, wf); > validate(from_init_list); > > -#ifndef _GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS > +#if _GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS > // PR125548 leads to incorrect densities being used > Distribution from_count(2, InputType(0), InputType(1), wf); > validate(from_count); > @@ -96,10 +96,10 @@ test_engine_calls() > { > constexpr std::size_t bits = __builtin_popcountg(URBG::max() - > URBG::min()); > constexpr std::size_t calls > -#ifdef _GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS > - = (std::numeric_limits<double>::digits + bits - 1) / bits; > -#else > +#if _GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS > = (std::numeric_limits<RealType>::digits + bits - 1) / bits; > +#else > + = (std::numeric_limits<double>::digits + bits - 1) / bits; > #endif > > struct wrapper : URBG > diff --git > a/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/operators/accessors_exact.cc > > b/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/operators/accessors_exact.cc > index 469ed3fac46..e8e00acab73 100644 > --- > a/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/operators/accessors_exact.cc > +++ > b/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/operators/accessors_exact.cc > @@ -1,4 +1,4 @@ > -// { dg-options "-D_GLIBCXX_USE_RESULT_TYPE_FOR_PIECEWISE_DENSITIES" } > +// { dg-options "-D_GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS=2" } > // { dg-do run { target c++11 } } > // { dg-require-cstdint "" } > #include "accessors.cc" > diff --git > a/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/operators/accessors_fallback.cc > > b/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/operators/accessors_fallback.cc > index 1f7269a879c..b803786368f 100644 > --- > a/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/operators/accessors_fallback.cc > +++ > b/libstdc++-v3/testsuite/26_numerics/random/piecewise_linear_distribution/operators/accessors_fallback.cc > @@ -1,4 +1,4 @@ > -// { dg-options "-D_GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS" } > +// { dg-options "-D_GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS=0" } > // { dg-do run { target c++11 } } > // { dg-require-cstdint "" } > #include "accessors.cc" > -- > 2.55.0 >
