mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 00:52:02 +00:00
Fix UBSan report in "round"
This commit is contained in:
parent
9c111a7bdb
commit
eb0473c3f9
@ -84,10 +84,12 @@
|
|||||||
# define NO_SANITIZE_UNDEFINED __attribute__((__no_sanitize__("undefined")))
|
# define NO_SANITIZE_UNDEFINED __attribute__((__no_sanitize__("undefined")))
|
||||||
# define NO_SANITIZE_ADDRESS __attribute__((__no_sanitize__("address")))
|
# define NO_SANITIZE_ADDRESS __attribute__((__no_sanitize__("address")))
|
||||||
# define NO_SANITIZE_THREAD __attribute__((__no_sanitize__("thread")))
|
# define NO_SANITIZE_THREAD __attribute__((__no_sanitize__("thread")))
|
||||||
|
# define ALWAYS_INLINE_NO_SANITIZE_UNDEFINED __attribute__((__always_inline__, __no_sanitize__("undefined")))
|
||||||
#else /// It does not work in GCC. GCC 7 cannot recognize this attribute and GCC 8 simply ignores it.
|
#else /// It does not work in GCC. GCC 7 cannot recognize this attribute and GCC 8 simply ignores it.
|
||||||
# define NO_SANITIZE_UNDEFINED
|
# define NO_SANITIZE_UNDEFINED
|
||||||
# define NO_SANITIZE_ADDRESS
|
# define NO_SANITIZE_ADDRESS
|
||||||
# define NO_SANITIZE_THREAD
|
# define NO_SANITIZE_THREAD
|
||||||
|
# define ALWAYS_INLINE_NO_SANITIZE_UNDEFINED ALWAYS_INLINE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// A template function for suppressing warnings about unused variables or function results.
|
/// A template function for suppressing warnings about unused variables or function results.
|
||||||
|
@ -101,7 +101,8 @@ struct IntegerRoundingComputation
|
|||||||
return scale;
|
return scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ALWAYS_INLINE T computeImpl(T x, T scale)
|
/// Integer overflow is Ok.
|
||||||
|
static ALWAYS_INLINE_NO_SANITIZE_UNDEFINED T computeImpl(T x, T scale)
|
||||||
{
|
{
|
||||||
switch (rounding_mode)
|
switch (rounding_mode)
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
9223372036854775700
|
6
tests/queries/0_stateless/01676_round_int_ubsan.sql
Normal file
6
tests/queries/0_stateless/01676_round_int_ubsan.sql
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
-- Overflow during integer rounding is implementation specific behaviour.
|
||||||
|
-- This test allows to be aware if the impkementation changes.
|
||||||
|
-- Changing the implementation specific behaviour is Ok.
|
||||||
|
-- and should not be treat as incompatibility (simply update test result then).
|
||||||
|
|
||||||
|
SELECT round(-9223372036854775808, -2);
|
Loading…
Reference in New Issue
Block a user