[jdk11u-dev] RFR: 8326109: GCC 13 reports maybe-uninitialized warnings for jni.cpp with dtrace enabled

Andrew John Hughes andrew at openjdk.org
Wed Feb 21 00:56:57 UTC 2024


On Sat, 17 Feb 2024 21:46:12 GMT, Andrew John Hughes <andrew at openjdk.org> wrote:

> This is a simple fix that allows newer versions of `gcc` to build OpenJDK without `--disable-warnings-as-errors` (i.e. the default)
> 
> When `dtrace` is enabled, the compilation of `jni.cpp` throws up a number of `maybe-uninitialized` warnings due to the expansion of the `DTRACE_PROBE` macros from `sdt.hpp` e.g.
> 
> ~~~
> In file included from /localhome/andrew/projects/openjdk/upstream/jdk11u-dev/src/hotspot/share/prims/jni.cpp:88:
> In destructor 'DTraceReturnProbeMark_NewStringUTF::~DTraceReturnProbeMark_NewStringUTF()',
>     inlined from '_jstring* jni_NewStringUTF(JNIEnv*, const char*)' at /localhome/andrew/projects/openjdk/upstream/jdk11u-dev/src/hotspot/share/prims/jni.cpp:2524:1:
> /home/andrew/builder/11u-dev/hotspot/variant-server/gensrc/dtracefiles/hotspot_jni.h:4179:1: error: 'ret' may be used uninitialized [-Werror=maybe-uninitialized]
>  4179 | DTRACE_PROBE1 (hotspot_jni, NewStringUTF__return, arg1)
>       | ^~~~~~~~~~~~~
> /localhome/andrew/projects/openjdk/upstream/jdk11u-dev/src/hotspot/share/utilities/dtrace.hpp:33:24: note: in definition of macro 'DTRACE_ONLY'
>    33 | #define DTRACE_ONLY(x) x
>       | ^
> /localhome/andrew/projects/openjdk/upstream/jdk11u-dev/src/hotspot/share/prims/jni.cpp:2512:1: note: in expansion of macro 'DT_RETURN_MARK_DECL'
>  2512 | DT_RETURN_MARK_DECL(NewStringUTF, jstring
>       | ^~~~~~~~~~~~~~~~~~~
> /localhome/andrew/projects/openjdk/upstream/jdk11u-dev/src/hotspot/share/prims/jni.cpp:2513:23: note: in expansion of macro 'HOTSPOT_JNI_NEWSTRINGUTF_RETURN'
>  2513 | , HOTSPOT_JNI_NEWSTRINGUTF_RETURN(_ret_ref));
>       | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
> ~~~
> 
> I don't see the same on 17u as `-Wno-maybe-uninitialized` is one of a number of warnings disabled in `CompileJvm.gmk`. This 11u only patch does the more specific fix of disabling the warning on `jni.cpp` only and only when `dtrace` is enabled.

Thanks Paul.

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

PR Comment: https://git.openjdk.org/jdk11u-dev/pull/2525#issuecomment-1955580445


More information about the jdk-updates-dev mailing list