Skip to content

repr(align(N)) not respected for uninhabited enum #149256

@theemathas

Description

@theemathas

I tried this code:

enum Never {}

#[repr(align(4))]
enum Thing { Variant(Never) }

fn main() {
    assert_eq!(1, align_of::<Thing>());
}

I expected the alignment of Thing to be 4, as per the repr attribute, so the assertion should fail. Instead, the program runs without errors.

Meta

Reproducible on the playground with version 1.93.0-nightly (2025-11-22 94b49fd998d6723e0a92)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-alignArea: alignment control (`repr(align(N))` and so on)A-enumArea: Enums (discriminated unions, or more generally ADTs (algebraic data types))A-layoutArea: Memory layout of typesA-reprArea: the `#[repr(stuff)]` attributeC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions