From 8e9aa9c6b09541830234f17fe615d0879b1af3cb Mon Sep 17 00:00:00 2001 From: Monty Date: Wed, 4 Dec 2024 12:58:00 +0200 Subject: [PATCH] Fix MariadDB to compile with gcc 7.5.0 gcc 7.5.0 does not understand __attribute__((no_sanitize("undefined")) I moved the usage of this attribute from sql/set_var.h to include/my_attribute.h and created a macro for it depending on compiler used. --- include/my_attribute.h | 8 +++++++- sql/set_var.h | 5 +++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/include/my_attribute.h b/include/my_attribute.h index c8e980702b6..e88947fb142 100644 --- a/include/my_attribute.h +++ b/include/my_attribute.h @@ -70,5 +70,11 @@ # endif /* GNUC >= 3.1 */ #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__ #endif + +#endif /* _my_attribute_h */ diff --git a/sql/set_var.h b/sql/set_var.h index 416993e5c34..483027e57d7 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -26,6 +26,7 @@ #endif #include +#include class sys_var; class set_var; @@ -247,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("undefined"))) + __attribute_no_sanitize__ uchar *session_var_ptr(THD *thd) const { return ((uchar*)&(thd->variables)) + offset; } - __attribute__((no_sanitize("undefined"))) + __attribute_no_sanitize__ uchar *global_var_ptr() const { return ((uchar*)&global_system_variables) + offset; }