Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
dtolnay opened this issue Apr 15, 2018 · 2 comments
Closed
Labels
I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness regression-from-stable-to-stable Performance or correctness regression from one stable version to another.

Comments

@dtolnay
Copy link
Member

dtolnay commented Apr 15, 2018

#![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.)

@dtolnay dtolnay added the regression-from-stable-to-stable Performance or correctness regression from one stable version to another. label Apr 15, 2018
@glandium
Copy link
Contributor

Clearly from #45225 rather than a followup, as it's happening in nightly-2017-11-21 and not in nightly-2017-11-20.

@ishitatsuyuki ishitatsuyuki added the I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness label Apr 15, 2018
@nox
Copy link
Contributor

nox commented Apr 15, 2018

This is not specific to i32 but to the enum using both signed extremums of its representation type:

#[derive(Debug)]
#[repr(i8)]
enum E {
    Min = -128i8,
    Max = 127i8,
}

bors added a commit that referenced this issue Apr 18, 2018
Properly handle ranges of signed enums using both extremums (fixes #49973)

Fixes #49973.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness regression-from-stable-to-stable Performance or correctness regression from one stable version to another.
Projects
None yet
Development

No branches or pull requests

4 participants