Skip to content

integer overflow in CTFE implementation of rotate_left #61406

Closed
@RalfJung

Description

@RalfJung

The following code ICEs when compiled with a rustc with debug-assertions enabled:

const X: i16 = 0i16.rotate_left(124);

The problem is in the implementation of rotate_left, specifically in this line:

let inv_shift_bits = (width_bits - raw_shift_bits) % width_bits;

The subtraction overflows here.

Cc @oli-obk

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions