Skip to content

ICE because uninhabited types and drop flags don't mix #17987

Closed
@ben0x539

Description

@ben0x539
enum Foo {}
impl Drop for Foo {
    fn drop(&mut self) {}
}

fn main() {
    unsafe { std::ptr::read(&1u8 as *const u8 as *const Foo) };
}

=> task 'rustc' failed at 'assertion failed: type_is_zero_size(bcx.ccx(), block_ty)'

Producing the value of the uninhabited type with transmute instead of ptr::read works "as expected". Another workaround is, of course, #![unsafe_no_drop_flag]. ;)

Metadata

Metadata

Assignees

No one assigned

    Labels

    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