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

The min/max macros make hotspot tests fail to build with GCC 6

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b174
    • Verification:
      Not verified

      Backports

        Description

        Building hotspot with GCC 6 is currently broken because hotspot fails to build tests:

        In file included from /home/omajid/rpmbuild/BUILD/java-9-openjdk-9.0.0.126-1.fc24.x86_64/jdk9/test/fmw/gtest/include/gtest/gtest.h:54:0,
                         from /home/omajid/rpmbuild/BUILD/java-9-openjdk-9.0.0.126-1.fc24.x86_64/jdk9/hotspot/test/native/unittest.hpp:29,
                         from /home/omajid/rpmbuild/BUILD/java-9-openjdk-9.0.0.126-1.fc24.x86_64/jdk9/hotspot/test/native/runtime/test_instanceKlass.cpp:28:
        /usr/include/c++/6.1.1/limits:320:11: error: macro "min" requires 2 arguments, but only 1 given
               min() _GLIBCXX_USE_NOEXCEPT { return _Tp(); }
                   ^
        /usr/include/c++/6.1.1/limits:324:11: error: macro "max" requires 2 arguments, but only 1 given
               max() _GLIBCXX_USE_NOEXCEPT { return _Tp(); }
                   ^
        /usr/include/c++/6.1.1/limits:387:11: error: macro "min" requires 2 arguments, but only 1 given
               min() _GLIBCXX_USE_NOEXCEPT { return false; }
                   ^

        hotspot/src/share/vm/utilities/globalDefinitions.hpp defines min and max macros:

        1166 #define max(a,b) Do_not_use_max_use_MAX2_instead
        1167 #define min(a,b) Do_not_use_min_use_MIN2_instead

        These macros are included first, and then the limits header is included which defines functions called min and max again:

        min() _GLIBCXX_USE_NOEXCEPT { return false; }
        max() _GLIBCXX_USE_NOEXCEPT { return true; }

        And the compiler doesn't like the "macros" here.

        There's a GCC bug that explains their position on this issue: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=29989

        A quick fix - assuming hotspot want to keep defining min()/max() macros - is to include the limits header first and then include the hotspot's #define's.

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                eosterlund Erik Österlund
                Reporter:
                omajid Omair Majid
                Votes:
                1 Vote for this issue
                Watchers:
                8 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: