boostorg / boostorg/safe_numerics
modulo interval arithmetic produces incorrect results
Open
- Dominant language
- C++
- Stars
- 222
- Forks
- 46
- PR merge metrics
- No merged PRs in 30d
Description
The modulo interval arithmetic produces incorrect results. The resulting interval can be _smaller_ than the possible values that could arise at runtime. I have an example on GitHub that produces this incorrect behavior in boost 1.80.
https://godbolt.org/z/36M3za3Px
```c++
safe_signed_range<0, 100, native, loose_trap_policy> a{const_safe_t<50>{}};
safe_signed_range<1, 100, native, loose_trap_policy> b{const_safe_t<100>{}};
auto c = a % b;
```
`c` ends up with an interval of 0 to 0 inclusive, even though it contains the value `50`.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.