mirror of
https://github.com/luxfi/intx.git
synced 2026-10-30 16:22:26 +00:00
For `udivrem` with divisor being `uint128` (2 words) the Knuth division branch is dead because it handles divisors with more than 2 words. However, the compiler or static analyzer will compile this branch and report array out-of-bounds access (e.g. GCC-15, Clang Analyzer 21). Fix this by adding more hints about expected value ranges.
14 lines
306 B
C++
14 lines
306 B
C++
#include <intx/intx.hpp>
|
|
|
|
using namespace intx;
|
|
|
|
extern "C" div_result<uint64_t> UDIVREM_2BY1(uint128 u, uint64_t d, uint64_t v)
|
|
{
|
|
return udivrem_2by1(u, d, v);
|
|
}
|
|
|
|
extern "C" void UDIVREM_4BY4(uint256& q, uint256& r, const uint256& u, const uint256& d) noexcept
|
|
{
|
|
std::tie(q, r) = udivrem(u, d);
|
|
}
|