Integrated: 8346160: Fix -Wzero-as-null-pointer-constant warnings from explicit casts
Kim Barrett
kbarrett at openjdk.org
Mon Dec 16 04:27:40 UTC 2024
On Fri, 13 Dec 2024 17:23:05 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:
> Please review this change that removes -Wzero-as-null-pointer-constant
> warnings from explicit casts of a literal 0 to a pointer type. Different
> versions of gcc seem to warn about different cases changed here, but all of
> these showed up as a warning in some testing, whether Oracle CI, GHA sanity
> tests, or local cross-builds using Oracle's devkits for that.
>
> Some of the changes simply replace a cast of 0 with nullptr.
>
> The UNIX_PATH_MAX macro definitions in attachListener_{aix,posix}.cpp is
> changed to use a C++11 feature for obtaining the size of a non-static data
> member without requiring an instance.
> https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2253.html
> I guess I need to propose an update to the style guide to mention this feature.
>
> In CompressedKlassPointers::initialize, casting
> CompressedClassSpaceBaseAddress to a pointer type was triggering the warning
> in release builds for some reason. That's not a literal 0, even though it *is*
> a constant 0 in a release build. Changed to avoid that cast rather than trying
> to argue with some versions of the compiler.
>
> Although different gcc versions on different platforms seemed to vary whether
> warning about each of these, this actually seems to be all of the explict
> casts of a literal 0 to a pointer in HotSpot. Though because of the varied
> behaviors, new ones might slip in later.
>
> Testing: mach5 tier1, GHA sanity tests, both with and without the warning enabled.
This pull request has now been integrated.
Changeset: c88e081a
Author: Kim Barrett <kbarrett at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/c88e081a6a0a00d7e7e5f2337f942a1d6c3b5110
Stats: 6 lines in 5 files changed: 0 ins; 0 del; 6 mod
8346160: Fix -Wzero-as-null-pointer-constant warnings from explicit casts
Reviewed-by: stefank, dholmes
-------------
PR: https://git.openjdk.org/jdk/pull/22740
More information about the hotspot-dev
mailing list