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

fix name clash of assert macro in debug.hpp with libc's assert macro

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 9
    • Fix Version/s: 12
    • Component/s: hotspot

      Description

      As reported in:

      https://bugs.openjdk.java.net/show_bug.cgi?id=100297

       Description From Radics Péter 2013-02-02 10:34:52 PDT

      Created an attachment (id=288) [details]
      Rename assert macro to assert_vm as it conflicts with libc's assert.

      hotspot/src/share/vm/utilities/debug.hpp defines an assert macro with two
      parameters. This macro definition clashes with libc's assert macro from
      <assert.h> (and to the best of my knowledge it's undefined behavior to redefine
      assert like this).

      The name clash causes build failures if any of the files using debug.hpp
      directly or indirectly include <assert.h> (or <cassert>), too.

      This doesn't seem to happen with libstdc++, but this error is triggered if
      trying to build with libc++ (http://libcxx.llvm.org).

      I propose changing the name of the assert macro defined in debug.hpp to
      assert_vm (based on the fact that this macro is used solely in the vm
      subsystem).

      I've broken up the patches to three parts, these should be applied in this
      order:

      1) patch-assert-vm-1.txt changes only the assert macro to assert_vm only in
      debug.hpp (note: this patch assumes that the typo fix from bug 100294 is
      already applied)
      2) patch-assert-vm-2.txt removes the trickery used in
      hotspot/src/share/vm/shark/llvmHeaders.hpp that was applied to avoid the
      name-clash brought forth by including LLVM headers
      3) fix-assert-vm-users.sh changes all other references to assert(cond, msg) to
      assert_vm(cond, msg). This script should be run in hotspot/src. I decided to
      post a fix-up script instead of a patch because the patch would be huge (there
      are a lot of uses of the "new" assert macro.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                dholmes David Holmes
              • Votes:
                1 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                • Created:
                  Updated: