mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Avoid UBSan report in aggregate function sum
This commit is contained in:
parent
dca0cbf4eb
commit
d9cb1c1bdd
@ -148,7 +148,7 @@ class AggregateFunctionAvg final : public AggregateFunctionAvgBase<AvgFieldType<
|
||||
public:
|
||||
using AggregateFunctionAvgBase<AvgFieldType<T>, UInt64, AggregateFunctionAvg<T>>::AggregateFunctionAvgBase;
|
||||
|
||||
void add(AggregateDataPtr place, const IColumn ** columns, size_t row_num, Arena *) const final
|
||||
void NO_SANITIZE_UNDEFINED add(AggregateDataPtr place, const IColumn ** columns, size_t row_num, Arena *) const final
|
||||
{
|
||||
this->data(place).numerator += static_cast<const DecimalOrVectorCol<T> &>(*columns[0]).getData()[row_num];
|
||||
++this->data(place).denominator;
|
||||
|
1
tests/queries/0_stateless/01660_sum_ubsan.reference
Normal file
1
tests/queries/0_stateless/01660_sum_ubsan.reference
Normal file
@ -0,0 +1 @@
|
||||
4233720368547758080
|
3
tests/queries/0_stateless/01660_sum_ubsan.sql
Normal file
3
tests/queries/0_stateless/01660_sum_ubsan.sql
Normal file
@ -0,0 +1,3 @@
|
||||
-- Aggregate function 'sum' allows overflow with two's complement arithmetics.
|
||||
-- This contradicts the standard SQL semantic and we are totally fine with it.
|
||||
SELECT sum(-8000000000000000000) FROM numbers(11);
|
Loading…
Reference in New Issue
Block a user