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

ICE: returning array with Const Generic size from mem::uninitialized() #61422

Closed
SephVelut opened this issue Jun 1, 2019 · 1 comment · Fixed by #61380
Closed

ICE: returning array with Const Generic size from mem::uninitialized() #61422

SephVelut opened this issue Jun 1, 2019 · 1 comment · Fixed by #61380
Labels
A-const-generics Area: const generics (parameters and arguments) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@SephVelut
Copy link

SephVelut commented Jun 1, 2019

error: internal compiler error: src/librustc/ty/sty.rs:2311: expected constant usize, got Const {
    ty: usize,
    val: Param(
        SIZE/#0,
    ),
}

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:637:9
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
error: aborting due to previous error
#![feature(const_generics)]
use std::mem;

fn foo<const SIZE: usize>() {
    let arr: [u8; SIZE] = unsafe {
        let mut array: [u8; SIZE] = mem::uninitialized();
        
        array // remove and removes error
    };
}
@varkor
Copy link
Member

varkor commented Jun 1, 2019

#61380 should fix this.

Edit: I've confirmed locally that this is fixed and will add a test to the pull request.

@varkor varkor added A-const-generics Area: const generics (parameters and arguments) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 1, 2019
varkor added a commit to varkor/rust that referenced this issue Jun 2, 2019
Centril added a commit to Centril/rust that referenced this issue Jun 2, 2019
…eddyb

Fix some issues with `unwrap_usize` instead of `assert_usize`

Fixes rust-lang#61337.
Fixes rust-lang#61341.
Fixes rust-lang#61422.

r? @eddyb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-generics Area: const generics (parameters and arguments) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants