RFR: 8338331: Fix -Wzero-as-null-pointer-constant warnings from CHECK_0 in jni.cpp
Kim Barrett
kbarrett at openjdk.org
Tue Aug 13 22:45:59 UTC 2024
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
-------------
Commit messages:
- CHECK_0 in jni.cpp
Changes: https://git.openjdk.org/jdk/pull/20575/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=20575&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8338331
Stats: 10 lines in 1 file changed: 0 ins; 0 del; 10 mod
Patch: https://git.openjdk.org/jdk/pull/20575.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/20575/head:pull/20575
PR: https://git.openjdk.org/jdk/pull/20575
More information about the hotspot-dev
mailing list