Skip to content

Incorrect std::mem::size_of_var for extern types #106577

Closed
@OpatrilPeter

Description

@OpatrilPeter

Hello, following code on nightly playground returns zero, indicating extern type behaving like ZST, while in comparison, size_of fails to compile. According to the RFC, panicking or compilation failure should happen, so this behavior seem incorrect.

#![feature(extern_types)]

extern {
    type Foo;
}

pub fn test() -> usize {
    let ptr: *mut Foo = std::ptr::null_mut();
    unsafe{std::mem::size_of_val::<Foo>(&*ptr)}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-extern_types`#![feature(extern_types)]`requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions