[jdk11u-dev] RFR: 8326109: GCC 13 reports maybe-uninitialized warnings for jni.cpp with dtrace enabled
Andrew John Hughes
andrew at openjdk.org
Sat Feb 17 21:50:09 UTC 2024
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.
-------------
Commit messages:
- 8326109: GCC 13 reports maybe-uninitialized warnings for jni.cpp with dtrace enabled
Changes: https://git.openjdk.org/jdk11u-dev/pull/2525/files
Webrev: https://webrevs.openjdk.org/?repo=jdk11u-dev&pr=2525&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8326109
Stats: 4 lines in 1 file changed: 4 ins; 0 del; 0 mod
Patch: https://git.openjdk.org/jdk11u-dev/pull/2525.diff
Fetch: git fetch https://git.openjdk.org/jdk11u-dev.git pull/2525/head:pull/2525
PR: https://git.openjdk.org/jdk11u-dev/pull/2525
More information about the jdk-updates-dev
mailing list