diff --git a/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdBits.inline.hpp b/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdBits.inline.hpp index 4bbd0c8ae182d..0b939d63f78ce 100644 --- a/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdBits.inline.hpp +++ b/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdBits.inline.hpp @@ -138,7 +138,7 @@ inline void JfrTraceIdBits::store(jbyte bits, const T* ptr) { // goes away with minor code perturbations, such as replacing function calls // with equivalent code directly inlined. PRAGMA_DIAG_PUSH - PRAGMA_DISABLE_GCC_WARNING("-Wstringop-overflow") + PRAGMA_STRINGOP_OVERFLOW_IGNORED set(bits, traceid_tag_byte(ptr)); PRAGMA_DIAG_POP } diff --git a/src/hotspot/share/utilities/compilerWarnings.hpp b/src/hotspot/share/utilities/compilerWarnings.hpp index bea99d69ebbea..9d0f9d4eccbaf 100644 --- a/src/hotspot/share/utilities/compilerWarnings.hpp +++ b/src/hotspot/share/utilities/compilerWarnings.hpp @@ -66,6 +66,10 @@ #define PRAGMA_STRINGOP_TRUNCATION_IGNORED #endif +#ifndef PRAGMA_STRINGOP_OVERFLOW_IGNORED +#define PRAGMA_STRINGOP_OVERFLOW_IGNORED +#endif + #ifndef PRAGMA_NONNULL_IGNORED #define PRAGMA_NONNULL_IGNORED #endif diff --git a/src/hotspot/share/utilities/compilerWarnings_gcc.hpp b/src/hotspot/share/utilities/compilerWarnings_gcc.hpp index b76e7fa7e1bef..ebde4ea95d6ca 100644 --- a/src/hotspot/share/utilities/compilerWarnings_gcc.hpp +++ b/src/hotspot/share/utilities/compilerWarnings_gcc.hpp @@ -50,6 +50,12 @@ #define PRAGMA_STRINGOP_TRUNCATION_IGNORED PRAGMA_DISABLE_GCC_WARNING("-Wstringop-truncation") #endif +// Disable -Wstringop-overflow which is introduced in GCC 7. +// https://gcc.gnu.org/gcc-7/changes.html +#if !defined(__clang_major__) && (__GNUC__ >= 7) +#define PRAGMA_STRINGOP_OVERFLOW_IGNORED PRAGMA_DISABLE_GCC_WARNING("-Wstringop-overflow") +#endif + #define PRAGMA_NONNULL_IGNORED \ PRAGMA_DISABLE_GCC_WARNING("-Wnonnull")