[libc-commits] [libc] [libc] fix -Wmissing-braces (PR #77345)

via libc-commits libc-commits at lists.llvm.org
Mon Jan 8 09:31:50 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Nick Desaulniers (nickdesaulniers)

<details>
<summary>Changes</summary>

Fixes the following errors observed on the aarch64 fullbuild:

    /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc/src/__support/HashTable/generic/bitmask_impl.inc:116:13:
    error: suggest braces around initialization of subobject
    [-Werror,-Wmissing-braces]
        return {static_cast<bitmask_t>(mask_available().word ^ repeat_byte(0x80))};
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                {                                                                }
    In file included from
    /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc/src/search/hdestroy.cpp:10:
    /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc/src/__support/HashTable/table.h:336:41:
    error: suggest braces around initialization of subobject
    [-Werror,-Wmissing-braces]
      iterator end() const { return {0, 0, {0}, *this}; }
                                            ^
                                            {}

Link: https://lab.llvm.org/buildbot/#/builders/223/builds/33868/steps/6/logs/stdio
Link: https://github.com/llvm/llvm-project/pull/74506


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


2 Files Affected:

- (modified) libc/src/__support/HashTable/generic/bitmask_impl.inc (+1-1) 
- (modified) libc/src/__support/HashTable/table.h (+1-1) 


``````````diff
diff --git a/libc/src/__support/HashTable/generic/bitmask_impl.inc b/libc/src/__support/HashTable/generic/bitmask_impl.inc
index b825cb5fbc44a8..d0cb342a60cd9c 100644
--- a/libc/src/__support/HashTable/generic/bitmask_impl.inc
+++ b/libc/src/__support/HashTable/generic/bitmask_impl.inc
@@ -113,7 +113,7 @@ struct Group {
   }
 
   LIBC_INLINE IteratableBitMask occupied() const {
-    return {static_cast<bitmask_t>(mask_available().word ^ repeat_byte(0x80))};
+    return {{static_cast<bitmask_t>(mask_available().word ^ repeat_byte(0x80))}};
   }
 };
 } // namespace internal
diff --git a/libc/src/__support/HashTable/table.h b/libc/src/__support/HashTable/table.h
index d70ca4d2338056..9b2f3beea9965e 100644
--- a/libc/src/__support/HashTable/table.h
+++ b/libc/src/__support/HashTable/table.h
@@ -333,7 +333,7 @@ struct HashTable {
     return {0, full_capacity() - available_slots,
             Group::load_aligned(&control(0)).occupied(), *this};
   }
-  iterator end() const { return {0, 0, {0}, *this}; }
+  iterator end() const { return {0, 0, {{0}}, *this}; }
 
   LIBC_INLINE ENTRY *find(const char *key) {
     uint64_t primary = oneshot_hash(key);

``````````

</details>


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


More information about the libc-commits mailing list