summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--googletest/src/gtest.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index e04a1c6..46d8d21 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -310,7 +310,8 @@ namespace internal {
// than kMaxRange.
UInt32 Random::Generate(UInt32 range) {
// These constants are the same as are used in glibc's rand(3).
- state_ = (1103515245U*state_ + 12345U) % kMaxRange;
+ // Use wider types than necessary to prevent unsigned overflow diagnostics.
+ state_ = static_cast<UInt32>(1103515245ULL*state_ + 12345U) % kMaxRange;
GTEST_CHECK_(range > 0)
<< "Cannot generate a number in the range [0, 0).";