JDK-8266176 : -Wmaybe-uninitialized happens in libArrayIndexOutOfBoundsExceptionTest.c
  • Type: Sub-task
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 17
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2021-04-28
  • Updated: 2021-12-02
  • Resolved: 2021-04-29
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 17
11.0.15Fixed 17 b21Fixed
Related Reports
Relates :  
Description
/home/ysuenaga/git-forked/jdk/test/hotspot/jtreg/runtime/exceptionMsgs/ArrayIndexOutOfBoundsException/libArrayIndexOutOfBoundsExceptionTest.c: In function 'Java_ArrayIndexOutOfBoundsExceptionTest_doNativeBooleanArrayRegionStore':
/home/ysuenaga/git-forked/jdk/test/hotspot/jtreg/runtime/exceptionMsgs/ArrayIndexOutOfBoundsException/libArrayIndexOutOfBoundsExceptionTest.c:51:4: warning: 'content' may be used uninitialized [-Wmaybe-uninitialized]
   51 |   (*env)->Set##NameType##ArrayRegion(env, array, start, len, content); \
      |   ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/ysuenaga/git-forked/jdk/test/hotspot/jtreg/runtime/exceptionMsgs/ArrayIndexOutOfBoundsException/libArrayIndexOutOfBoundsExceptionTest.c:54:1: note: in expansion of macro 'REGIONACCESS'
   54 | REGIONACCESS(jboolean, Boolean)
      | ^~~~~~~~~~~~
Comments
Fix Request (11u). PR: https://github.com/openjdk/jdk11u-dev/pull/678 GCC 11 compatibility backport, test fix, applies cleanly.
30-11-2021

Changeset: 39abac98 Author: Yasumasa Suenaga <ysuenaga@openjdk.org> Date: 2021-04-29 07:59:35 +0000 URL: https://git.openjdk.java.net/jdk/commit/39abac98f9803897e40c32d5bcb35bd25c348d2a
29-04-2021

Oops! Sorry you are right I was reading things the wrong way. We fill in the array from the buffer.
28-04-2021

I think it is reasonable to initialize `buf` in this case because `SetBooleanArrayRegion()` writes contents into jbooleanArray from native buffer. https://docs.oracle.com/en/java/javase/16/docs/specs/jni/functions.html#setprimitivetypearrayregion-routines PR is available. I will send it if you are ok. https://github.com/openjdk/jdk/pull/3744/files
28-04-2021

This seems bogus - the content buffer is for the function to write into, it doesn't have to be initialized.
28-04-2021