This ensures that the new definition of std::generate_canonical has a
different mangled name from the old one, so that TUs compiled with GCC
16 will be sure to use the new definition, even if the linker also sees
a symbol instantiated from the old definition. We use the same _V2
inline namespace as used elsewhere (std::_V2::condition_variable,
std::_V2::__rotate, and std::chrono::_V2::system_clock), and use a macro
to add it conditionally so that it's not used for the ABI-unstable
gnu-versioned-namespace configuration.
We can simplify the 26_numerics/random/pr60037-neg.cc test to only use
one dg-error without a line number, so that it matches any of the three
relevant static_assert failures for this test: the one from _Adaptor in
<bits/random.h> and the ones from the new and old definitions of
std::generate_canonical in <bits/random.tcc>. Without this change, the
line number for the dg-error matching the <bits/random.tcc> error
depends on the _GLIBCXX_USE_OLD_GENERATE_CANONICAL macro, which is
awkward to depend on in the test (because DejaGnu sees all dg-error
directives, it doesn't care if they're guarded by #ifdef preprocessor
checks).
libstdc++-v3/ChangeLog:
* include/bits/random.h [!_GLIBCXX_USE_OLD_GENERATE_CANONICAL]
(generate_canonical): Use inline namespace _V2.
* include/bits/random.tcc [!_GLIBCXX_USE_OLD_GENERATE_CANONICAL]
(generate_canonical): Likewise.
* testsuite/26_numerics/random/pr60037-neg.cc: Remove lineno so
that one dg-error matches both diagnostics.
Reviewed-by: Tomasz KamiĆski <tkaminsk@redhat.com>
// std::uniform_random_bit_generator is defined in <bits/uniform_int_dist.h>
+#ifndef _GLIBCXX_USE_OLD_GENERATE_CANONICAL
+_GLIBCXX_BEGIN_INLINE_ABI_NAMESPACE(_V2)
+#endif
/**
* @brief A function template for converting the output of a (integral)
* uniform random number generator to a floatng point result in the range
typename _UniformRandomNumberGenerator>
_RealType
generate_canonical(_UniformRandomNumberGenerator& __g);
+#ifndef _GLIBCXX_USE_OLD_GENERATE_CANONICAL
+_GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2)
+#endif
/// @cond undocumented
// Implementation-space details.
constexpr bool __is_power_of_2_less_1(_Rng __range)
{ return ((__range + 1) & __range) == 0; };
+_GLIBCXX_BEGIN_INLINE_ABI_NAMESPACE(_V2)
/** Produce a random floating-point value in the range [0..1)
*
* The result of `std::generate_canonical<RealT,digits>(urng)` is a
}
}
}
+_GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2)
#pragma GCC diagnostic pop
auto x = std::generate_canonical<std::size_t,
std::numeric_limits<std::size_t>::digits>(urng);
-// { dg-error "static assertion failed: template argument must be a floating point type" "" { target *-*-* } 271 }
-
-// { dg-error "static assertion failed: template argument must be a floating point type" "" { target *-*-* } 3650 }
-
+// { dg-error "static assertion failed: template argument must be a floating point type" "" { target *-*-* } 0 }