From 488b1e673988c8e4687ce0e9e4ef2b38a57d2664 Mon Sep 17 00:00:00 2001 From: sdong Date: Mon, 16 Mar 2020 13:47:28 -0700 Subject: [PATCH] Fix an error in db_bench with gcc 4.8 (#6537) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- tools/db_bench_tool.cc | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/tools/db_bench_tool.cc b/tools/db_bench_tool.cc index 80e07ee6a..9e2a37967 100644 --- a/tools/db_bench_tool.cc +++ b/tools/db_bench_tool.cc @@ -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 { public: - NormalDistribution(unsigned int min, unsigned int max) : - BaseDistribution(min, max), - // 99.7% values within the range [min, max]. - std::normal_distribution((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)(_min + _max) / 2.0 /*mean*/, + (double)(_max - _min) / 6.0 /*stddev*/), + gen_(rd_()) {} + private: virtual unsigned int Get() override { return static_cast((*this)(gen_)); @@ -1543,10 +1544,11 @@ class UniformDistribution : public BaseDistribution, public std::uniform_int_distribution { public: - UniformDistribution(unsigned int min, unsigned int max) : - BaseDistribution(min, max), - std::uniform_int_distribution(min, max), - gen_(rd_()) {} + UniformDistribution(unsigned int _min, unsigned int _max) + : BaseDistribution(_min, _max), + std::uniform_int_distribution(_min, _max), + gen_(rd_()) {} + private: virtual unsigned int Get() override { return (*this)(gen_);