Skip to content

Raw pointer deref of uninhabited type allowed in const fn #77694

Closed
@DutchGhost

Description

@DutchGhost

The code below compiles as of 1.46, but I'm not sure it should, since it dereferences a raw pointer in a const block, which is only allowed in nightly with the #![feature(const_raw_ptr_deref)] flag:

const unsafe fn unreachable() -> ! {
    use core::convert::Infallible;
    
    const INFALLIBLE: *const Infallible = [].as_ptr();
    match *INFALLIBLE {}
}

fn main() {
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)A-raw-pointersArea: raw pointers, MaybeUninit, NonNullA-stabilityArea: `#[stable]`, `#[unstable]` etc.C-bugCategory: This is a bug.P-highHigh priority

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions