Fix an error in db_bench with gcc 4.8 (#6537)
Summary: I start to see following failures: tools/db_bench_tool.cc: In constructor ‘rocksdb::NormalDistribution::NormalDistribution(unsigned int, unsigned int)’: tools/db_bench_tool.cc:1528:58: error: declaration of ‘max’ shadows a member of 'this' [-Werror=shadow] NormalDistribution(unsigned int min, unsigned int max) : ^ tools/db_bench_tool.cc:1528:58: error: declaration of ‘min’ shadows a member of 'this' [-Werror=shadow] tools/db_bench_tool.cc: In constructor ‘rocksdb::UniformDistribution::UniformDistribution(unsigned int, unsigned int)’: tools/db_bench_tool.cc:1546:59: error: declaration of ‘max’ shadows a member of 'this' [-Werror=shadow] UniformDistribution(unsigned int min, unsigned int max) : ^ tools/db_bench_tool.cc:1546:59: error: declaration of ‘min’ shadows a member of 'this' [-Werror=shadow] when I build from GCC 4.8. Rename those variables to fix the problem. Pull Request resolved: https://github.com/facebook/rocksdb/pull/6537 Test Plan: make all with the compiler that used to show the failure. Differential Revision: D20448741 fbshipit-source-id: 18bcf012dbe020f22f79038a9b08f447befa2574
This commit is contained in:
parent
d66908091d
commit
488b1e6739
@ -1484,9 +1484,8 @@ static enum DistributionType StringToDistributionType(const char* ctype) {
|
||||
|
||||
class BaseDistribution {
|
||||
public:
|
||||
BaseDistribution(unsigned int min, unsigned int max) :
|
||||
min_value_size_(min),
|
||||
max_value_size_(max) {}
|
||||
BaseDistribution(unsigned int _min, unsigned int _max)
|
||||
: min_value_size_(_min), max_value_size_(_max) {}
|
||||
virtual ~BaseDistribution() {}
|
||||
|
||||
unsigned int Generate() {
|
||||
@ -1525,12 +1524,14 @@ class FixedDistribution : public BaseDistribution
|
||||
class NormalDistribution
|
||||
: public BaseDistribution, public std::normal_distribution<double> {
|
||||
public:
|
||||
NormalDistribution(unsigned int min, unsigned int max) :
|
||||
BaseDistribution(min, max),
|
||||
// 99.7% values within the range [min, max].
|
||||
std::normal_distribution<double>((double)(min + max) / 2.0 /*mean*/,
|
||||
(double)(max - min) / 6.0 /*stddev*/),
|
||||
gen_(rd_()) {}
|
||||
NormalDistribution(unsigned int _min, unsigned int _max)
|
||||
: BaseDistribution(_min, _max),
|
||||
// 99.7% values within the range [min, max].
|
||||
std::normal_distribution<double>(
|
||||
(double)(_min + _max) / 2.0 /*mean*/,
|
||||
(double)(_max - _min) / 6.0 /*stddev*/),
|
||||
gen_(rd_()) {}
|
||||
|
||||
private:
|
||||
virtual unsigned int Get() override {
|
||||
return static_cast<unsigned int>((*this)(gen_));
|
||||
@ -1543,10 +1544,11 @@ class UniformDistribution
|
||||
: public BaseDistribution,
|
||||
public std::uniform_int_distribution<unsigned int> {
|
||||
public:
|
||||
UniformDistribution(unsigned int min, unsigned int max) :
|
||||
BaseDistribution(min, max),
|
||||
std::uniform_int_distribution<unsigned int>(min, max),
|
||||
gen_(rd_()) {}
|
||||
UniformDistribution(unsigned int _min, unsigned int _max)
|
||||
: BaseDistribution(_min, _max),
|
||||
std::uniform_int_distribution<unsigned int>(_min, _max),
|
||||
gen_(rd_()) {}
|
||||
|
||||
private:
|
||||
virtual unsigned int Get() override {
|
||||
return (*this)(gen_);
|
||||
|
Loading…
x
Reference in New Issue
Block a user