diff --git a/include/my_attribute.h b/include/my_attribute.h index e88947fb142..9bfb6ab50be 100644 --- a/include/my_attribute.h +++ b/include/my_attribute.h @@ -71,10 +71,14 @@ #endif /* gcc 7.5.0 does not support __attribute__((no_sanitize("undefined")) */ -#if defined(__clang__) -#define __attribute_no_sanitize__ __attribute__((no_sanitize("undefined"))) -#else -#define __attribute_no_sanitize__ +#ifndef ATTRIBUTE_NO_UBSAN +# if (GCC_VERSION >= 8000) || defined(__clang__) +# define ATTRIBUTE_NO_UBSAN __attribute__((no_sanitize("undefined"))) +# elif (GCC_VERSION >= 6001) +# define ATTRIBUTE_NO_UBSAN __attribute__((no_sanitize_undefined)) +# else +# define ATTRIBUTE_NO_UBSAN +# endif #endif #endif /* _my_attribute_h */ diff --git a/sql/set_var.h b/sql/set_var.h index 483027e57d7..58b23e14bf7 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -248,11 +248,11 @@ protected: Typically it's the same as session_value_ptr(), but it's different, for example, for ENUM, that is printed as a string, but stored as a number. */ - __attribute_no_sanitize__ + ATTRIBUTE_NO_UBSAN uchar *session_var_ptr(THD *thd) const { return ((uchar*)&(thd->variables)) + offset; } - __attribute_no_sanitize__ + ATTRIBUTE_NO_UBSAN uchar *global_var_ptr() const { return ((uchar*)&global_system_variables) + offset; }