Skip to content

ICE: const_fn feature  #43754

Closed
Closed
@ZhangHanDong

Description

@ZhangHanDong
#![feature(const_fn)]
const fn foo(x: usize) -> usize {
    return x;
}
fn main() {
    [0; foo(2)];
}

or

#![feature(const_fn)]
const unsafe fn foo(x: usize) -> usize {
    return x;
}
fn main() {
    [0; unsafe {foo(2)}];

}

Note: rustc 1.21.0-nightly (cbbe17a 2017-08-07) running on x86_64-apple-darwin

Run: Cargo build

ICEs with:

Compiling hello v0.1.0 (file:///.../hello)
error: internal compiler error: src/librustc_mir/hair/cx/expr.rs:472: constant evaluation of repeat count yielded Tuple([])

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.21.0-nightly (cbbe17aa7 2017-08-07) running on x86_64-apple-darwin

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:486:8
note: Run with `RUST_BACKTRACE=1` for a backtrace.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions