[libc-commits] [libc] [libc] Avoid add_with_carry name shadowing issue (PR #215815)
Lewis Crawford via libc-commits
libc-commits at lists.llvm.org
Wed Aug 12 08:01:26 PDT 2026
https://github.com/LewisCrawford created https://github.com/llvm/llvm-project/pull/215815
Use fully namespace-qualified calls to the scalar versions of `add_with_carry` in `big_int.h` to avoid build errors due to function-name shadowing issues on MSVC when it is configured without using 2-phase lookup for templates.
This disambiguates the 2 templated functions:
- `add_with_carry(dst, rhs)` in the `multiword` namespace
- `add_with_carry(a, b, carry_in, carry_out)` in the outer libc namespace
>From d75965b4677c116295ac21f7fdb652e4c0f98cf8 Mon Sep 17 00:00:00 2001
From: Lewis Crawford <lcrawford at nvidia.com>
Date: Tue, 11 Aug 2026 15:11:47 +0000
Subject: [PATCH] [libc] Avoid add_with_carry name shadowing issue
Use fully namespace-qualified calls to the scalar
versions of `add_with_carry` in `big_int.h` to avoid
build errors due to function-name shadowing issues
on MSVC when it is configured without using 2-phase
lookup for templates.
This disambiguates the 2 templated functions:
- `add_with_carry(dst, rhs)` in the `multiword` namespace
- `add_with_carry(a, b, carry_in, carry_out)` in the outer libc namespace
---
libc/src/__support/big_int.h | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/libc/src/__support/big_int.h b/libc/src/__support/big_int.h
index 29da5b9866bb0..5d2675909f2fb 100644
--- a/libc/src/__support/big_int.h
+++ b/libc/src/__support/big_int.h
@@ -124,10 +124,14 @@ LIBC_INLINE constexpr DoubleWide<word> mul2(word a, word b) {
word no_carry = 0;
word carry = 0;
[[maybe_unused]] word _ = 0; // unused carry variable.
- lo_digit = add_with_carry<word>(lo_digit, shiftl(step2), no_carry, carry);
- hi_digit = add_with_carry<word>(hi_digit, shiftr(step2), carry, _);
- lo_digit = add_with_carry<word>(lo_digit, shiftl(step3), no_carry, carry);
- hi_digit = add_with_carry<word>(hi_digit, shiftr(step3), carry, _);
+ lo_digit = LIBC_NAMESPACE::add_with_carry<word>(lo_digit, shiftl(step2),
+ no_carry, carry);
+ hi_digit =
+ LIBC_NAMESPACE::add_with_carry<word>(hi_digit, shiftr(step2), carry, _);
+ lo_digit = LIBC_NAMESPACE::add_with_carry<word>(lo_digit, shiftl(step3),
+ no_carry, carry);
+ hi_digit =
+ LIBC_NAMESPACE::add_with_carry<word>(hi_digit, shiftr(step3), carry, _);
return DoubleWide<word>(lo_digit, hi_digit);
}
}
More information about the libc-commits
mailing list