Fix UBSan report in runningDifference

This commit is contained in:
Alexey Milovidov 2021-01-22 23:46:51 +03:00
parent 4afcb94a8a
commit 4047542b61
3 changed files with 3 additions and 1 deletions

View File

@ -46,7 +46,7 @@ private:
/// It is possible to track value from previous columns, to calculate continuously across all columnss. Not implemented. /// It is possible to track value from previous columns, to calculate continuously across all columnss. Not implemented.
template <typename Src, typename Dst> template <typename Src, typename Dst>
static void process(const PaddedPODArray<Src> & src, PaddedPODArray<Dst> & dst, const NullMap * null_map) static NO_SANITIZE_UNDEFINED void process(const PaddedPODArray<Src> & src, PaddedPODArray<Dst> & dst, const NullMap * null_map)
{ {
size_t size = src.size(); size_t size = src.size();
dst.resize(size); dst.resize(size);
@ -76,6 +76,7 @@ private:
else else
{ {
auto cur = src[i]; auto cur = src[i];
/// Overflow is Ok.
dst[i] = static_cast<Dst>(cur) - prev; dst[i] = static_cast<Dst>(cur) - prev;
prev = cur; prev = cur;
} }

View File

@ -0,0 +1 @@
SELECT k, d, i FROM (SELECT t.1 AS k, t.2 AS v, runningDifference(v) AS d, runningDifference(cityHash64(t.1)) AS i FROM (SELECT arrayJoin([(NULL, 65535), ('a', 7), ('a', 3), ('b', 11), ('b', 2), ('', -9223372036854775808)]) AS t)) WHERE i = 9223372036854775807;