Skip to content

Commit 823f596

Browse files
authored
Merge pull request ClickHouse#80137 from rschu1ze/quantile-bfloat16-ubsan
Fix ubsan issue in quantileBFloat16
2 parents 4a23e77 + 041d821 commit 823f596

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/AggregateFunctions/QuantileBFloat16Histogram.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,13 @@ struct QuantileBFloat16Histogram
115115
using Pair = PairNoInit<Float32, Weight>;
116116

117117
template <typename T>
118-
static inline T safeCast(Float32 x)
118+
static T safeCast(Float32 x)
119119
{
120120
if constexpr (!std::is_floating_point_v<T>)
121121
{
122-
if (unlikely(x > std::numeric_limits<T>::max()))
122+
if (x >= std::numeric_limits<T>::max()) [[unlikely]]
123123
return std::numeric_limits<T>::max();
124-
if (unlikely(x < std::numeric_limits<T>::min()))
124+
if (x <= std::numeric_limits<T>::min()) [[unlikely]]
125125
return std::numeric_limits<T>::min();
126126
}
127127
return static_cast<T>(x);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
2105-07-28 04:08:00
2+
2105-07-28 04:08:00
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
SELECT quantileBFloat16('2106-02-07 06:28:14'::DateTime('Europe/Amsterdam'));
2+
SELECT quantileBFloat16('2106-02-07 06:28:15'::DateTime('Europe/Amsterdam'));

0 commit comments

Comments
 (0)