[lld] [lld][NFC] Silence -Wuninitialized GCC warnings. (PR #75183)

Jacek Caban via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 12 05:34:49 PST 2023


https://github.com/cjacek created https://github.com/llvm/llvm-project/pull/75183

A workaround for warnings reported in #69101. Use of those variables is guarded by lastType, so I don't think that they are actually used uninitialized and I don't see the warning on GCC 12.3.

>From a9924742c7c032e437674369e8d64c466ff15d71 Mon Sep 17 00:00:00 2001
From: Jacek Caban <jacek at codeweavers.com>
Date: Tue, 12 Dec 2023 14:30:49 +0100
Subject: [PATCH] [lld][NFC] Silence -Wuninitialized GCC warnings.

---
 lld/COFF/Writer.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp
index 7b1ff8071e2e3d..89e0f5b2df7441 100644
--- a/lld/COFF/Writer.cpp
+++ b/lld/COFF/Writer.cpp
@@ -560,7 +560,7 @@ void Writer::createECCodeMap() {
   codeMap.clear();
 
   std::optional<chpe_range_type> lastType;
-  Chunk *first, *last;
+  Chunk *first = nullptr, *last = nullptr;
 
   auto closeRange = [&]() {
     if (lastType) {



More information about the llvm-commits mailing list