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

Miri does not know about niches #633

Closed
gnzlbg opened this issue Feb 14, 2019 · 1 comment
Closed

Miri does not know about niches #633

gnzlbg opened this issue Feb 14, 2019 · 1 comment

Comments

@gnzlbg
Copy link

gnzlbg commented Feb 14, 2019

This passes on the playground:

#![feature(rustc_attrs)]
#[rustc_layout_scalar_valid_range_start(0)]
#[rustc_layout_scalar_valid_range_end(15)]
pub struct Imm4(pub u8);

fn main() {
    let _y = unsafe { Imm4(3_u8) };
    let _z = unsafe { Imm4(22_u8) };
}
@RalfJung
Copy link
Member

RalfJung commented Feb 14, 2019

This is a duplicate of #508.

If you look at the MIR, there is no moment here in which an Imm4 is actually assigned, meaning there is no reason to assume that we even have a valid Imm4. let _y = unsafe { Imm4(3_u8) }; becomes (_1.0: u8) = const 3u8;, which is an assignment at type u8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants