PR libstdc++/68925
        * include/experimental/random (randint): Use temporary instead of
        thread_local static.

Tested powerpc64le-linux, committed to trunk.

commit 71544b3d1abd1c9a2d47ef664ce696b750232e0f
Author: Jonathan Wakely <jwak...@redhat.com>
Date:   Wed Jan 18 17:16:10 2017 +0000

    PR68925 don't use thread_local static for stateless object
    
        PR libstdc++/68925
        * include/experimental/random (randint): Use temporary instead of
        thread_local static.

diff --git a/libstdc++-v3/include/experimental/random 
b/libstdc++-v3/include/experimental/random
index 9d5415e..e28df5d 100644
--- a/libstdc++-v3/include/experimental/random
+++ b/libstdc++-v3/include/experimental/random
@@ -54,8 +54,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       static_assert(is_integral<_IntType>::value && sizeof(_IntType) > 1,
                    "argument must be an integer type");
       using _Dist = std::uniform_int_distribution<_IntType>;
-      static thread_local _Dist __dist;
-      return __dist(_S_randint_engine(), typename _Dist::param_type{__a, __b});
+      // This relies on the fact our uniform_int_distribution is stateless,
+      // otherwise we'd need a static thread_local _Dist and pass it
+      // _Dist::param_type{__a, __b}.
+      return _Dist(__a, __b)(_S_randint_engine());
     }
 
   inline void

Reply via email to