Files
Paweł BylicaandGitHub 5268560350 Fix udivrem dead branch causing static analysis failures (#349)
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.
2025-11-13 16:02:58 +01:00

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);
}