RFR: 8332189: Enable -Wzero-as-null-pointer-constant for gcc/clang
David Holmes
dholmes at openjdk.org
Tue Feb 3 06:34:02 UTC 2026
On Fri, 30 Jan 2026 00:16:54 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:
> 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.
Looks reasonable to me. Thanks
-------------
Marked as reviewed by dholmes (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/29497#pullrequestreview-3743249921
More information about the hotspot-dev
mailing list