RFR: 8338331: Fix -Wzero-as-null-pointer-constant warnings from CHECK_0 in jni.cpp

Aleksey Shipilev shade at openjdk.org
Wed Aug 14 13:06:51 UTC 2024


On Tue, 13 Aug 2024 22:41:19 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

> Please review this change to some macros in jni.cpp.  These macros were using
> CHECK_0 when calling functions that can "throw" exceptions.  However, the
> return type involved is provided by a macro argument, and is a pointer type
> for some uses of the macros.  This triggered -Wzero-as-null-pointer-constant
> warnings when enabled.
> 
> To remove the warnings, these CHECK_0() uses are changed to CHECK_() with an
> argument expression that constructs and value-initializes a temporary of that
> return type, e.g. `ResultType{}`.  Value-initialization of a scalar type is
> zero-initialization. Zero-initialization of a scalar type initializes it to
> the value obtained by convertion a literal 0 to that type.  So a zero of the
> appropriate type for arithmetic types.  For pointer types it's initialized to
> nullptr, without triggering the warning.
> 
> Testing: mach5 tier1

Marked as reviewed by shade (Reviewer).

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

PR Review: https://git.openjdk.org/jdk/pull/20575#pullrequestreview-2238104942


More information about the hotspot-dev mailing list