[llvm] [llvm] Fix - gcc error: buf may be used uninitialized [-Werror=maybe-uninitialized] (PR #213578)

via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 2 19:00:47 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-adt

Author: Arun Thangamani (arun-thmn)

<details>
<summary>Changes</summary>

When compiled with `gcc`, the uninitialized `buf` triggers a warning. Since some external projects (e.g., `TPP-MLIR`) treat warnings as errors, the build fails. This patch initializes `buf` to eliminate the warning and prevent those build failures

---
Full diff: https://github.com/llvm/llvm-project/pull/213578.diff


1 Files Affected:

- (modified) llvm/include/llvm/ADT/Hashing.h (+1-1) 


``````````diff
diff --git a/llvm/include/llvm/ADT/Hashing.h b/llvm/include/llvm/ADT/Hashing.h
index bb965bea86d0c..b05598486abc7 100644
--- a/llvm/include/llvm/ADT/Hashing.h
+++ b/llvm/include/llvm/ADT/Hashing.h
@@ -306,7 +306,7 @@ template <typename... Ts> hash_code hash_combine(const Ts &...args) {
   constexpr size_t Total = hashing::detail::total_hashable_size<Ts...>();
   // Round up so `data()` is non-null when Total == 0; combine_bytes won't
   // read the buffer in that case (len=0 short-circuits in xxh3_64bits).
-  std::array<char, std::max<size_t>(1, Total)> buf;
+  std::array<char, std::max<size_t>(1, Total)> buf{};
   [[maybe_unused]] size_t off = 0;
   (hashing::detail::store_hashable_data(buf.data(), off, args), ...);
   return hashing::detail::combine_bytes(buf.data(), Total);

``````````

</details>


https://github.com/llvm/llvm-project/pull/213578


More information about the llvm-commits mailing list