[llvm] 1d9086b - Fix use of uninitialized member in constructor

Sven van Haastregt via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 7 04:09:29 PDT 2022


Author: Sven van Haastregt
Date: 2022-07-07T12:05:24+01:00
New Revision: 1d9086bf054c2e734940620d02d4451156b424e6

URL: https://github.com/llvm/llvm-project/commit/1d9086bf054c2e734940620d02d4451156b424e6
DIFF: https://github.com/llvm/llvm-project/commit/1d9086bf054c2e734940620d02d4451156b424e6.diff

LOG: Fix use of uninitialized member in constructor

The constructor does `Saver(Alloc)`, so `Alloc` should be
initialized first.  Move `Alloc` up in the declaration order.

Fixes a -Wuninitialized warning when building with GCC 12.1.

Reported-by: Mihail Atanassov <mihail.atanassov at arm.com>

Added: 
    

Modified: 
    llvm/include/llvm/IR/ModuleSummaryIndex.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/IR/ModuleSummaryIndex.h b/llvm/include/llvm/IR/ModuleSummaryIndex.h
index b76bc879fb45..f1dd29926278 100644
--- a/llvm/include/llvm/IR/ModuleSummaryIndex.h
+++ b/llvm/include/llvm/IR/ModuleSummaryIndex.h
@@ -1153,8 +1153,8 @@ class ModuleSummaryIndex {
 
   // Used in cases where we want to record the name of a global, but
   // don't have the string owned elsewhere (e.g. the Strtab on a module).
-  StringSaver Saver;
   BumpPtrAllocator Alloc;
+  StringSaver Saver;
 
   // The total number of basic blocks in the module in the per-module summary or
   // the total number of basic blocks in the LTO unit in the combined index.


        


More information about the llvm-commits mailing list