[libc-commits] [libc] [libc] Make bigint trivially constructable (PR #206277)
via libc-commits
libc-commits at lists.llvm.org
Sat Jun 27 12:26:34 PDT 2026
https://github.com/Sukumarsawant updated https://github.com/llvm/llvm-project/pull/206277
>From 1c07f07900f009398608b9d21ddd42aa26c2e304 Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Sun, 28 Jun 2026 00:16:39 +0530
Subject: [PATCH 1/2] test for constexpr failures
---
libc/src/__support/big_int.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libc/src/__support/big_int.h b/libc/src/__support/big_int.h
index 0e5c038ec356e..c1cf5b43fd1f5 100644
--- a/libc/src/__support/big_int.h
+++ b/libc/src/__support/big_int.h
@@ -358,7 +358,7 @@ struct BigInt {
LIBC_INLINE_VAR static constexpr size_t WORD_COUNT = Bits / WORD_SIZE;
- cpp::array<WordType, WORD_COUNT> val{}; // zero initialized.
+ cpp::array<WordType, WORD_COUNT> val; // zero initialized.
LIBC_INLINE constexpr BigInt() = default;
>From 7aabfa421ef39741ef5a8edeab6b294b7c1ca397 Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Sun, 28 Jun 2026 00:56:14 +0530
Subject: [PATCH 2/2] bigint changes
---
libc/src/__support/big_int.h | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/libc/src/__support/big_int.h b/libc/src/__support/big_int.h
index c1cf5b43fd1f5..c71dfacf51608 100644
--- a/libc/src/__support/big_int.h
+++ b/libc/src/__support/big_int.h
@@ -366,7 +366,8 @@ struct BigInt {
template <size_t OtherBits, bool OtherSigned, typename OtherWordType>
LIBC_INLINE constexpr BigInt(
- const BigInt<OtherBits, OtherSigned, OtherWordType> &other) {
+ const BigInt<OtherBits, OtherSigned, OtherWordType> &other)
+ : val{} {
using BigIntOther = BigInt<OtherBits, OtherSigned, OtherWordType>;
[[maybe_unused]] const bool should_sign_extend = Signed && other.is_neg();
@@ -491,7 +492,7 @@ struct BigInt {
LIBC_INLINE static constexpr BigInt one() { return BigInt(1); }
LIBC_INLINE static constexpr BigInt all_ones() { return ~zero(); }
LIBC_INLINE static constexpr BigInt min() {
- BigInt out;
+ BigInt out{};
if constexpr (SIGNED)
out.set_msb();
return out;
More information about the libc-commits
mailing list