https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105681

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Target Milestone|---                         |12.2
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2022-05-26
           Assignee|unassigned at gcc dot gnu.org      |redi at gcc dot gnu.org

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I think the compiler might have got stricter about diagnosing narrowing
conversions in non-type template arguments (I think I even reported a bug
saying it should do that!)

The problem is that size_t is a 16-bit unsigned int, so too small for the
values we use in the specializations:

  template<typename _UIntType, size_t __m,
           size_t __pos1, size_t __sl1, size_t __sl2,
           size_t __sr1, size_t __sr2,
           uint32_t __msk1, uint32_t __msk2,
           uint32_t __msk3, uint32_t __msk4,
           uint32_t __parity1, uint32_t __parity2,
           uint32_t __parity3, uint32_t __parity4>
    class simd_fast_mersenne_twister_engine

// ...

  typedef simd_fast_mersenne_twister_engine<uint32_t, 86243, 366,
                                            6, 7, 19, 1,
                                            0xfdbffbffU, 0xbff7ff3fU,
                                            0xfd77efffU, 0xbf9ff3ffU,
                                            0x00000001U, 0x00000000U,
                                            0x00000000U, 0xe9528d85U>
    sfmt86243;

We could change the size_t there to be a type with at least 32 bits to make it
work, but I think the right fix is to simply not defined those typedefs that
don't fit in 16 bits:

--- a/libstdc++-v3/include/ext/random
+++ b/libstdc++-v3/include/ext/random
@@ -346,6 +346,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                                            0xa3ac4000U, 0xecc1327aU>
     sfmt44497_64;

+#if __SIZE_WIDTH__ >= 32

   typedef simd_fast_mersenne_twister_engine<uint32_t, 86243, 366,
                                            6, 7, 19, 1,
@@ -396,6 +397,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                                            0xf8000001U, 0x89e80709U,
                                            0x3bd2b64bU, 0x0c64b1e4U>
     sfmt216091_64;
+#endif // __SIZE_WIDTH__ >= 32

 #endif // __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__


Everything in <ext/random> is a non-standard extension, so we're under no
obligation to provide any of it for standard conformance.

Reply via email to