[libcxx-commits] [libcxx] [libc++] Fix sub-overflow in std::gcd implementation (PR #117984)
via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Dec 2 13:21:40 PST 2024
================
@@ -55,7 +55,7 @@ template <class _Tp>
constexpr _LIBCPP_HIDDEN _Tp __gcd(_Tp __a, _Tp __b) {
static_assert(!is_signed<_Tp>::value, "");
- // From: https://lemire.me/blog/2013/12/26/fastest-way-to-compute-the-greatest-common-divisor
+ // From: https://lemire.me/blog/2024/04/13/greatest-common-divisor-the-extended-euclidean-algorithm-and-speed/
----------------
hiraditya wrote:
I believe this is Stein's algorithm (Can't find the link currently but this has a reference on https://aha.stanford.edu/sites/g/files/sbiybj20066/files/media/file/aha_050422_sreedhar_crypto_xgcd_1.pdf#page=14). Maybe we should write that instead of linking to a blogpost? But I'm not sure what the policy is about adding a link in the code. Can we add this link in a commit message instead?
https://github.com/llvm/llvm-project/pull/117984
More information about the libcxx-commits
mailing list