Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
googletest
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
googletest
Commits
7890f721
Commit
7890f721
authored
Aug 07, 2017
by
Gennadiy Civil
Committed by
GitHub
Aug 07, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1180 from aconverse/master
Use wider types to prevent unsigned overflow diagnostics
parents
eb261b4d
deb99a9d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
1 deletion
+2
-1
gtest.cc
googletest/src/gtest.cc
+2
-1
No files found.
googletest/src/gtest.cc
View file @
7890f721
...
@@ -310,7 +310,8 @@ namespace internal {
...
@@ -310,7 +310,8 @@ namespace internal {
// than kMaxRange.
// than kMaxRange.
UInt32
Random
::
Generate
(
UInt32
range
)
{
UInt32
Random
::
Generate
(
UInt32
range
)
{
// These constants are the same as are used in glibc's rand(3).
// 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
)
GTEST_CHECK_
(
range
>
0
)
<<
"Cannot generate a number in the range [0, 0)."
;
<<
"Cannot generate a number in the range [0, 0)."
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment