Skip to content

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

Closed
@SephVelut

Description

@SephVelut
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
    };
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-genericsArea: const generics (parameters and arguments)I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions