From 9071457d3f885bedaad7ce8c2ae29b65e34aa112 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Wed, 19 Aug 2020 21:04:31 +0300 Subject: [PATCH 1/2] Fix C++20 comparison calls recursively with reversed arguments in UInt128.h (over.match.oper#3.4.4 in gcc10) Due to [1], gcc10 reports: ../src/Common/UInt128.h:92:81: error: in C++20 this comparison calls the current function recursively with reversed arguments [-Werror] 92 | template bool inline operator == (T a, const UInt128 b) { return b == a; } [1]: http://eel.is/c++draft/over.match.oper#3.4.4 --- src/Common/UInt128.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Common/UInt128.h b/src/Common/UInt128.h index 497f49c8ef0..77bb60bef2b 100644 --- a/src/Common/UInt128.h +++ b/src/Common/UInt128.h @@ -89,8 +89,8 @@ struct UInt128 UInt128 & operator= (const UInt64 rhs) { low = rhs; high = 0; return *this; } }; -template bool inline operator == (T a, const UInt128 b) { return b == a; } -template bool inline operator != (T a, const UInt128 b) { return b != a; } +template bool inline operator == (T a, const UInt128 b) { return b.operator==(a); } +template bool inline operator != (T a, const UInt128 b) { return b.operator!=(a); } template bool inline operator >= (T a, const UInt128 b) { return b <= a; } template bool inline operator > (T a, const UInt128 b) { return b < a; } template bool inline operator <= (T a, const UInt128 b) { return b >= a; } From 99db9341a200c7abb3c5b03fa423bd8fbb80129c Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Wed, 19 Aug 2020 22:36:28 +0300 Subject: [PATCH 2/2] Fix -Werror=type-limits in AggregateFunctionTimeSeriesGroupSum.h (size_t() >= 0) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gcc10 reports: In file included from ../src/AggregateFunctions/AggregateFunctionTimeSeriesGroupSum.cpp:1: ../src/AggregateFunctions/AggregateFunctionTimeSeriesGroupSum.h: In instantiation of ‘void DB::AggregateFunctionTimeSeriesGroupSumData::add(DB::UInt64, DB::Int64, DB::Float64) [with bool rate = true; DB::UInt64 = long unsigned int; DB::Int64 = long int; DB::Float64 = double]’: ../src/AggregateFunctions/AggregateFunctionTimeSeriesGroupSum.h:246:34: required from ‘void DB::AggregateFunctionTimeSeriesGroupSum::add(DB::AggregateDataPtr, const DB::IColumn**, size_t, DB::Arena*) const [with bool rate = true; DB::AggregateDataPtr = char*; size_t = long unsigned int]’ ../src/AggregateFunctions/AggregateFunctionTimeSeriesGroupSum.h:239:10: required from here ../src/AggregateFunctions/AggregateFunctionTimeSeriesGroupSum.h:113:71: error: comparison of unsigned expression in ‘>= 0’ is always true [-Werror=type-limits] 113 | while (result[i].first > it_ss->second.dps.front().first && i >= 0) | ~~^~~~ ../src/AggregateFunctions/AggregateFunctionTimeSeriesGroupSum.h: In instantiation of ‘void DB::AggregateFunctionTimeSeriesGroupSumData::add(DB::UInt64, DB::Int64, DB::Float64) [with bool rate = false; DB::UInt64 = long unsigned int; DB::Int64 = long int; DB::Float64 = double]’: ../src/AggregateFunctions/AggregateFunctionTimeSeriesGroupSum.h:246:34: required from ‘void DB::AggregateFunctionTimeSeriesGroupSum::add(DB::AggregateDataPtr, const DB::IColumn**, size_t, DB::Arena*) const [with bool rate = false; DB::AggregateDataPtr = char*; size_t = long unsigned int]’ ../src/AggregateFunctions/AggregateFunctionTimeSeriesGroupSum.h:239:10: required from here ../src/AggregateFunctions/AggregateFunctionTimeSeriesGroupSum.h:113:71: error: comparison of unsigned expression in ‘>= 0’ is always true [-Werror=type-limits] --- src/AggregateFunctions/AggregateFunctionTimeSeriesGroupSum.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/AggregateFunctions/AggregateFunctionTimeSeriesGroupSum.h b/src/AggregateFunctions/AggregateFunctionTimeSeriesGroupSum.h index 3ec40455cf3..be0a3eb4af5 100644 --- a/src/AggregateFunctions/AggregateFunctionTimeSeriesGroupSum.h +++ b/src/AggregateFunctions/AggregateFunctionTimeSeriesGroupSum.h @@ -108,13 +108,13 @@ struct AggregateFunctionTimeSeriesGroupSumData else result.emplace_back(std::make_pair(t, v)); } - size_t i = result.size() - 1; + ssize_t i = result.size() - 1; //reverse find out the index of timestamp that more than previous timestamp of t while (result[i].first > it_ss->second.dps.front().first && i >= 0) i--; i++; - while (i < result.size() - 1) + while (i < ssize_t(result.size()) - 1) { result[i].second += it_ss->second.getval(result[i].first); i++;