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

Enable -Wzero-as-null-pointer-constant

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • None
    • infrastructure

      Enable -Wzero-as-null-pointer-constant to enforce the HotSpot Style Guide's admonishment against using 0 for pointers - JDK-8327173.

      There are currently a *lot* of these warnings, though many come from a few frequently included headers. Some have obvious and fairly trivial fixes. Others may involve a bit more work. So code changes needed to permit enabling the warning should probably be broken into multiple PRs.

      Enabling this warning does not help with backsliding on the use of NULL where nullptr should be used instead. At one time gcc sometimes complained about NULL or __null:
      https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77513
      But there was an explicit change to make this warning not apply to those cases:
      https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=752e7593b0f19af233a0b7e72daab8413662b605
      On the other hand, there's another gcc bug report that specifically requests the warning for NULL:
      https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114571

            kbarrett Kim Barrett
            kbarrett Kim Barrett
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: