this-pointer NULL-checks in hotspot codebase [-Wtautological-undefined-compare]
Erik Österlund
erik.osterlund at oracle.com
Fri Jul 12 08:22:04 UTC 2019
Hi Matthias,
Removing such NULL checks seems like a good idea in general due to the
undefined behaviour.
Worth mentioning though that there are some tricky ones, like in
markOopDesc* where this == NULL
means that the mark word has the "inflating" value. So we explicitly
check if this == NULL and
hope the compiler will not elide the check. Just gonna drop that one
here and run for it.
Thanks,
/Erik
On 2019-07-12 09:48, Baesken, Matthias wrote:
> Hello , when looking into the recent xlc16 / xlclang warnings I came across those 3 :
>
> /nightly/jdk/src/hotspot/share/adlc/formssel.cpp:1729:7: warning: 'this' pointer cannot be null in well-defined C++ code;
> comparison may be assumed to always evaluate to true [-Wtautological-undefined-compare]
> if( this != NULL ) {
> ^~~~ ~~~~
>
> /nightly/jdk/src/hotspot/share/adlc/formssel.cpp:3416:7: warning: 'this' pointer cannot be null in well-defined C++ code;
> comparison may be assumed to always evaluate to false [-Wtautological-undefined-compare]
> if( this == NULL ) return;
>
> /nightly/jdk/src/hotspot/share/libadt/set.cpp:46:7: warning: 'this' pointer cannot be null in well-defined C++ code;
> comparison may be assumed to always evaluate to false [-Wtautological-undefined-compare]
> if( this == NULL ) return os::strdup("{no set}");
>
>
> Do you think the NULL-checks can be removed or is there still some value in doing them ?
>
> Best regards, Matthias
More information about the hotspot-dev
mailing list