[11u]RFR[S]:8240715: fail to build with gcc 6.3.1 [-Werror=maybe-uninitialized]

linzang(臧琳) linzang at tencent.com
Sun Mar 8 08:23:02 UTC 2020


I made a tiny patch for this:
Please help to review.
Webrev: http://cr.openjdk.java.net/~lzang/11u/JDK-8240715/webrev/
Bug: https://bugs.openjdk.java.net/browse/JDK-8240715


BRs,
Lin

From: "linzang(臧琳)" <linzang at tencent.com>
Date: Saturday, March 7, 2020 at 12:33 AM
To: "jdk-updates-dev at openjdk.java.net" <jdk-updates-dev at openjdk.java.net>
Subject: [11u] fail to build with gcc 6.3.1 [-Werror=maybe-uninitialized]

Hi,
     The 11u-dev repo fail to build with gcc 6.3.1, error message:
====================================================
        In file included from / Source/jdk11u-dev/src/hotspot/cpu/x86/assembler_x86.inline.hpp:30:0,
                 from / Source/jdk11u-dev/src/hotspot/share/asm/assembler.inline.hpp:30,
                 from / Source/jdk11u-dev/src/hotspot/share/precompiled/precompiled.hpp:32:
/Source/jdk11u-dev/src/hotspot/share/code/codeCache.hpp: In member function 'void G1CollectedHeap::complete_cleaning(BoolObjectClosure*, bool)':
/Source/jdk11u-dev/src/hotspot/share/code/codeCache.hpp:377:5: error: 'iter.CodeBlobIterator<CompiledMethod, CompiledMethodFilter>::_code_blob' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     if (_code_blob == NULL) {
     ^~
/Source/jdk11u-dev/src/hotspot/share/gc/g1/g1CollectedHeap.cpp:3355:28: note: 'iter.CodeBlobIterator<CompiledMethod, CompiledMethodFilter>::_code_blob' was declared here
     CompiledMethodIterator iter = CompiledMethodIterator();
                            ^~~~
cc1plus: all warnings being treated as errors

The build can success with –disable-warnings-as-errors  or with simple change:
diff -r e5802f7424cf src/hotspot/share/code/codeCache.hpp
--- a/src/hotspot/share/code/codeCache.hpp      Fri May 24 13:52:33 2019 -0700
+++ b/src/hotspot/share/code/codeCache.hpp      Fri Mar 06 15:00:55 2020 +0800
@@ -322,6 +322,7 @@
  public:
   CodeBlobIterator(T* nm = NULL) {
+    _code_blob = NULL;
     if (Filter::heaps() == NULL) {
       return;
     }
diff -r e5802f7424cf src/hotspot/share/gc/shared/genCollectedHeap.cpp
--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp  Fri May 24 13:52:33 2019 -0700
+++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp  Fri Mar 06 15:00:55 2020 +0800
@@ -1146,6 +1146,7 @@
   size_t min_size = 0;   // "first" makes this conceptually infinite.
   ScratchBlock **smallest_ptr, *smallest;
   ScratchBlock  *cur = *prev_ptr;
+  smallest_ptr = NULL;
   while (cur) {
     assert(*prev_ptr == cur, "just checking");
     if (first || cur->num_words < min_size) {
-----------------------------------------------------------

So could this be a fix ?

BRs,
Lin


More information about the jdk-updates-dev mailing list