Skip to content

#[repr(C)] silently accepted on ADT enums #31692

Closed
@durka

Description

@durka

This code compiles without error or relevant warning:

#[repr(C)]
enum Foo { A { x: i32 }, B(i32), C }

#[repr(i32)]
enum Bar { Bar(i32), Baz(u32) }

But obviously the representation of the enum is still going to be undefined, and not integral or C-compatible (trivially checked by mem::size_of in this case).

There should be an error (probably infeasible) or at least a lint that is on by default.

@Aatch says there is already an issue about this, but I can't find it, so feel free to close as a duplicate if you can find it :)
cc @niconii

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.T-langRelevant to the language 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