Integrated: 8374446: Fix -Wzero-as-null-pointer-constant warnings in test_compressedKlass.cpp

Kim Barrett kbarrett at openjdk.org
Tue Jan 6 15:09:28 UTC 2026


On Fri, 2 Jan 2026 07:18:06 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

> Please review this simple change to a recently added gtest to avoid triggering
> -Wzero-as-null-pointer-constant warnings when that warning is enabled.
> 
> There are two parts to the change. One is just an obvious replacement of 0
> with nullptr.
> 
> The other is the removal of a gtest assertion. That assertion's predicate is
> attempting to verify the CompressedKlassPointers state has been initialized.
> But the test being used (null pointer <= base pointer) is technically invalid;
> ordered comparisons between a pointer and null are UB. And even ignoring that,
> the compiler may decide the comparison is tautologially true, or it may always
> be true at runtime, because pointer comparison is treated as unsigned by at
> least some compilers. It would be better done via an is_initialized() function
> in CompressedKlassPointers, or use == with the initial "uninitialized" value
> of -1. But we're already asserting initialization in the implementation of the
> base() function, so at least in debug builds we've already verified
> initialization. It doesn't seem worthwhile adding is_initialized() or breaking
> through the abstraction and using -1.
> 
> Testing: mach5 tier1

This pull request has now been integrated.

Changeset: 32144282
Author:    Kim Barrett <kbarrett at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/3214428203642e986c47eabc29ebdea93016b2c5
Stats:     3 lines in 1 file changed: 0 ins; 1 del; 2 mod

8374446: Fix -Wzero-as-null-pointer-constant warnings in test_compressedKlass.cpp

Reviewed-by: dholmes

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

PR: https://git.openjdk.org/jdk/pull/29016


More information about the hotspot-runtime-dev mailing list