Skip to content

We don't consistently handle overflows and numeric as-casts robustly #7151

Open

Description

@jieyouxu

In various places in the codebase, for various stable/unstable options, we are not very careful with how we handle potential underflow/overflows. The typical pattern looks like

  • Plain a + b or a - b (underflow/overflow potential; panic in debug, wraparound in release)
  • as-casts between integral numeric types with different ranges; typical pattern looks like a as isize/a as usize. Typically this has potential for bitwise reinterpretation to do funny things.

Activity

  1. added
    C-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICE
    A-robustnessArea: robustness of rustfmt
    on Sep 29, 2026
  2. added
    needs-triageThis issue or PR needs triaging to determine its status. Remove label once sufficiently triaged.
    on Sep 29, 2026
  3. removed
    needs-triageThis issue or PR needs triaging to determine its status. Remove label once sufficiently triaged.
    on Sep 29, 2026
  4. jieyouxu commented on Sep 29, 2026

    @jieyouxu
    MemberAuthor

    (NB: you can obviously use clippy restriction lints on bare arithmetic ops, the tradeoff there is that it makes arithmetic ops quite verbose 😆)

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

    A-robustnessArea: robustness of rustfmtC-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICE

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions