Skip to content

Implement checks for unchecked_* operations #646

Closed

Description

@celinval

Requested feature: RMC should detect failures when dealing with unchecked arithmetic operations.
Use case: Unchecked arithmetic operations assume that the operands respect some invariant. If they don't, the result has an undefined behavior. We should add checks to verify that all the invariants are respected.
Link to relevant documentation (Rust reference, Nomicon, RFC):
https://doc.rust-lang.org/std/primitive.u32.html
https://doc.rust-lang.org/std/primitive.i32.html
https://doc.rust-lang.org/std/primitive.f32.html#method.to_int_unchecked

Is this a breaking change? No

Activity

  1. added
    [F] Soundness
    on Nov 15, 2021
  2. changed the title [-]Implement arithmetic checks for unchecked operations[/-] [+]Implement checks for unchecked operations[/+] on Nov 15, 2021
  3. changed the title [-]Implement checks for unchecked operations[/-] [+]Implement checks for unchecked_* operations[/+] on Nov 15, 2021
  4. removed
    [F] Soundness
    on Jul 14, 2022
  5. celinval commented on Jul 14, 2022

    @celinval
    ContributorAuthor

    Removing soundness since we don't claim support to all UBs related to arithmetic operations.

  6. added
    [C] Feature / Enhancement
    and removed on Nov 9, 2022
  7. feliperodri commented on Nov 17, 2026

    @feliperodri
    Member

    Implemented: shift checks in 7fc9fa7, float_to_int range checks in 0dc09a7, add/sub/mul overflow checks in rvalue.rs. Repros 646-2 and 646-3 report the div and add UB on main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    [C] Feature / Enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions