aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2017-01-18 17:18:47 +0000
committerJonathan Wakely <redi@gcc.gnu.org>2017-01-18 17:18:47 +0000
commitb08fdbb8450a578846ad69b00b89a80ef24a5203 (patch)
treefc6bff688d2b70a42fe49ab4cdcb2d2855462fbb
parent46c4e8a1cf8a42947c38cf4a012e5fee45cdfe83 (diff)
downloadgcc-b08fdbb8450a578846ad69b00b89a80ef24a5203.zip
gcc-b08fdbb8450a578846ad69b00b89a80ef24a5203.tar.gz
gcc-b08fdbb8450a578846ad69b00b89a80ef24a5203.tar.bz2
PR68925 don't use thread_local static for stateless object
PR libstdc++/68925 * include/experimental/random (randint): Use temporary instead of thread_local static. From-SVN: r244584
-rw-r--r--libstdc++-v3/ChangeLog6
-rw-r--r--libstdc++-v3/include/experimental/random6
2 files changed, 10 insertions, 2 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index a499ae7..6b51357 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,9 @@
+2017-01-18 Jonathan Wakely <jwakely@redhat.com>
+
+ PR libstdc++/68925
+ * include/experimental/random (randint): Use temporary instead of
+ thread_local static.
+
2017-01-17 Joshua Conner <joshconner@google.com>
* crossconfig.m4: Add fuchsia OS.
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