MDEV-34770 GCC warning fix

kvm-bintar-trusty-x86: warning: ‘no_sanitize’ attribute directive
ignored [-Wattributes]

The attribute is supported since gcc 8.
This commit is contained in:
Aleksey Midenkov 2024-12-04 15:39:10 +03:00
parent 2bf9f0d422
commit aa9d5aea48
2 changed files with 10 additions and 6 deletions

View file

@ -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 */

View file

@ -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; }