Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8288093

Reconsider GCC compiler pragmas for disabling warnings

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 19
    • hotspot

      There are a few places in Hotspot where we disable the particular warnings with compiler pragmas. Unfortunately, those checks sometimes take the form of:

      ```
      // Disable -Wstringop-truncation which is introduced in GCC 8.
      // https://gcc.gnu.org/gcc-8/changes.html
      #if !defined(__clang_major__) && (__GNUC__ >= 8)
      #define PRAGMA_STRINGOP_TRUNCATION_IGNORED PRAGMA_DISABLE_GCC_WARNING("-Wstringop-truncation")
      #endif
      ```

      ...because touching the non-existent option with pragmas fails on old compilers, see for example JDK-8288048.

      In here:
       https://github.com/openjdk/jdk/pull/9090#pullrequestreview-1000840657

      ...Kim suggests to add `-Wunknown-pragmas` to `PRAGMA_DISABLE_GCC_WARNING` macro to make compilers eat up unknown pragmas unconditionally, thus eliminating the need for compiler-version-specific hacks like above.

            Unassigned Unassigned
            shade Aleksey Shipilev
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: