Skip to content

modulo interval arithmetic produces incorrect results #132

@lukevalenty

Description

@lukevalenty

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

    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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions