]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Make declaration and definition of generate_canonical consistent.
authorTomasz Kamiński <tkaminsk@redhat.com>
Wed, 17 Dec 2025 09:32:54 +0000 (10:32 +0100)
committerTomasz Kamiński <tkaminsk@redhat.com>
Wed, 17 Dec 2025 10:01:15 +0000 (11:01 +0100)
The r16-6177-g866bc8a9214b1d introduced type-constraint on _Urbg template
parameter in __glibcxx_concepts, with was inconsistent with declaration in
bits/random.h and definition in bits/random.tcc causing the missing symbol
errors in tests.

Furthermore, this made the mangled name of generate_canonical in C++20
mode different from older standard and previous versions of GCC.

libstdc++-v3/ChangeLog:

* include/bits/random.tcc (generate_canonical)
[!_GLIBCXX_USE_OLD_GENERATE_CANONICAL]: Use static_assert
instead of type-constraint on template parameter.
* testsuite/26_numerics/random/pr60037-neg.cc: Updated line
of error.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
libstdc++-v3/include/bits/random.tcc
libstdc++-v3/testsuite/26_numerics/random/pr60037-neg.cc

index 3c5288c2eab8eabba7f0ecce003e99d219316d3f..053307519b4bff9bd018537b0a08161350b7b3a1 100644 (file)
@@ -3619,12 +3619,6 @@ namespace __detail
   template <> const bool __is_rand_dist_float_v<long double> = true;
 #endif
 
-#ifdef __glibcxx_concepts
-# define _Uniform_random_bit_generator uniform_random_bit_generator
-#else
-# define _Uniform_random_bit_generator typename
-#endif
-
   // Note, this works even when (__range + 1) overflows:
   template <typename _Rng>
     constexpr bool __is_power_of_2_less_1(_Rng __range)
@@ -3646,10 +3640,13 @@ namespace __detail
    *  @since C++11
    */
   template<typename _RealT, size_t __digits,
-       _Uniform_random_bit_generator _Urbg>
+          typename _Urbg>
     _RealT
     generate_canonical(_Urbg& __urng)
     {
+#ifdef __glibcxx_concepts
+      static_assert(uniform_random_bit_generator<_Urbg>);
+#endif      
       static_assert(__is_rand_dist_float_v<_RealT>,
        "template argument must be a floating point type");
       static_assert(__digits != 0 && _Urbg::max() > _Urbg::min(),
index 06d659aae94f61854500d22f343b3f677840a440..13c4dc8724a45da2d476a75054277616d6081e02 100644 (file)
@@ -12,4 +12,5 @@ auto x = std::generate_canonical<std::size_t,
 
 // { 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 *-*-* } 3653 }
+// { dg-error "static assertion failed: template argument must be a floating point type" "" { target *-*-* } 3650 }
+