Integrated: 8338331: Fix -Wzero-as-null-pointer-constant warnings from CHECK_0 in jni.cpp
Kim Barrett
kbarrett at openjdk.org
Thu Aug 15 17:54:00 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
This pull request has now been integrated.
Changeset: 52d9d69d
Author: Kim Barrett <kbarrett at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/52d9d69db5c1853445a95794c5bf21243aefa852
Stats: 10 lines in 1 file changed: 0 ins; 0 del; 10 mod
8338331: Fix -Wzero-as-null-pointer-constant warnings from CHECK_0 in jni.cpp
Reviewed-by: dholmes, shade
-------------
PR: https://git.openjdk.org/jdk/pull/20575
More information about the hotspot-dev
mailing list