[PATCH] D34089: [llvm-stress] Ensure that the C++11 random device respects its min/max values (PR32585)
Simon Pilgrim via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 26 03:16:51 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL306281: [llvm-stress] Ensure that the C++11 random device respects its min/max values… (authored by RKSimon).
Changed prior to commit:
https://reviews.llvm.org/D34089?vs=102311&id=103916#toc
Repository:
rL LLVM
https://reviews.llvm.org/D34089
Files:
llvm/trunk/tools/llvm-stress/llvm-stress.cpp
Index: llvm/trunk/tools/llvm-stress/llvm-stress.cpp
===================================================================
--- llvm/trunk/tools/llvm-stress/llvm-stress.cpp
+++ llvm/trunk/tools/llvm-stress/llvm-stress.cpp
@@ -116,10 +116,14 @@
/// Make this like a C++11 random device
typedef uint32_t result_type;
- uint32_t operator()() { return Rand32(); }
static constexpr result_type min() { return 0; }
static constexpr result_type max() { return 0x7ffff; }
-
+ uint32_t operator()() {
+ uint32_t Val = Rand();
+ assert(Val <= max() && "Random value out of range");
+ return Val;
+ }
+
private:
unsigned Seed;
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34089.103916.patch
Type: text/x-patch
Size: 648 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170626/aeb1a3df/attachment.bin>
More information about the llvm-commits
mailing list