RFR: 8332189: Enable -Wzero-as-null-pointer-constant for gcc/clang

Kim Barrett kbarrett at openjdk.org
Tue Feb 3 06:15:36 UTC 2026


Please review this change which enables `-Wzero-as-null-pointer-constant`
warnings in HotSpot code when building with gcc or clang.

There are three parts to this change.

The first part augments the warning flags setup to support adding warning
options that are only applied to HotSpot, rather than the JDK as a whole.
There was previously some unused and possibly incomplete support for this when
using gcc. Note that the Windows/Visual Studio support hasn't been tested
much, and I think might not be working yet. I'm going to investigate that
further in followup work.

The second part enables `-Wzero-as-null-pointer-constant` for HotSpot code.
This follows the guidance to avoid such in the HotSpot Style Guide.

The third part removes a note in the HotSpot Style Guide about lingering uses
of literal 0 as a null pointer constant.  Those have been removed, and this
change will block backsliding.

Testing: mach5 tier1, GHA Sanity tests

Integration of this change needs to wait for JDK-8376758.

-------------

Commit messages:
 - remove obsolete note from style guide
 - enable -Wzero-as-null-pointer-constant for VM with gcc/clang
 - support hotspot-specific warnings

Changes: https://git.openjdk.org/jdk/pull/29497/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=29497&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8332189
  Stats: 40 lines in 3 files changed: 14 ins; 13 del; 13 mod
  Patch: https://git.openjdk.org/jdk/pull/29497.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/29497/head:pull/29497

PR: https://git.openjdk.org/jdk/pull/29497


More information about the hotspot-dev mailing list