Rust

Rust

Made by DeepSource

Found isize/usize enumeration with overflowing value RS-W1075

Bug risk
Major

Given enumerations with #[repr(isize)] or #[repr(usize)] contain values that may overflow/underflow on 32-bit machines. If intentional, ignore this issue.

Bad practice

#[repr(usize)]
enum NonPortable {
    X = 2_147_483_650, // more than i32::MAX
    Y,
}

#[repr(isize)]
enum NonPortable {
    X = -2_147_483_650, // less than i32::MIN
    Y,
}

Recommended

#[repr(u64)]
enum NonPortable {
    X = 2_147_483_650,
    Y,
}

#[repr(i64)]
enum NonPortable {
    X = -2_147_483_650,
    Y,
}