| 90 | |
| 91 | template <typename Int> |
| 92 | [[nodiscard]] bool SubtractWithOverflowGeneric(Int u, Int v, Int* out) { |
| 93 | #if USE_CHECKED_ARITHMETIC_BUILTINS |
| 94 | return __builtin_sub_overflow(u, v, out); |
| 95 | #else |
| 96 | if constexpr (sizeof(Int) < 4) { |
| 97 | using UpscaledInt = upscaled_int32_t<Int>; |
| 98 | auto r = static_cast<UpscaledInt>(u) - static_cast<UpscaledInt>(v); |
| 99 | *out = static_cast<Int>(r); |
| 100 | return r != *out; |
| 101 | } else { |
| 102 | return SafeIntSubtractWithOverflow(u, v, out); |
| 103 | } |
| 104 | #endif |
| 105 | } |
| 106 | |
| 107 | template <typename Int> |
| 108 | [[nodiscard]] bool MultiplyWithOverflowGeneric(Int u, Int v, Int* out) { |
nothing calls this directly
no outgoing calls
no test coverage detected