Skip to content

Incorrect niche filling if enum contains both i32 min and i32 max variants #49973

Closed
@dtolnay

Description

@dtolnay
#![allow(dead_code)]

#[derive(Debug)]
#[repr(i32)]
enum E {
    Min = -2147483648i32,
    Max = 2147483647i32,
}

fn main() {
    println!("{:?}", Some(E::Min));
}

Rust 1.23.0 correctly prints Some(Min). Rust 1.24.0 incorrectly prints None.

Mentioning @eddyb because this sounds potentially relevant to #45225 or follow-on optimization.

(Discovered by @udoprog in #rust.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundnessregression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions