RFR: 8336080: Fix -Wzero-as-null-pointer-constant warnings in ClassLoaderStats ctor

David Holmes dholmes at openjdk.org
Thu Jul 11 02:58:54 UTC 2024


On Wed, 10 Jul 2024 12:15:23 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

> Please review this change to member initializers in the ClassLoaderStats
> constructor.
> 
> The initial value for members of pointer type are changed from 0 to nullptr.
> 
> The initializers for members of oop type are changed from a value of 0 to
> using value initialization. In debug builds this calls the provided default
> ctor for the (debug-only) oop class, which initialized the underlying value to
> nullptr. In release builds (where oop is a type alias for oopDesc*) this is a
> zero initialization of the pointer-typed member, but without triggering
> -Wzero-as-null-pointer-constant warnings.
> 
> Testing: mach5 tier1

src/hotspot/share/classfile/classLoaderStats.hpp line 87:

> 85:     _cld(nullptr),
> 86:     _class_loader(),
> 87:     _parent(),

Why are these not initialized with `nullptr` given we have code like:

(cls._class_loader == nullptr ? ...)

?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20109#discussion_r1673329417


More information about the hotspot-runtime-dev mailing list