Skip to content

ICE: Struct cannot be packed and aligned #43317

Closed
@Boddlnagg

Description

@Boddlnagg

The following code (playground) ICEs with error: internal compiler error: /checkout/src/librustc/ty/layout.rs:603: Struct cannot be packed and aligned:

#![feature(repr_align, attr_literals)]

#[repr(packed)]
#[repr(align(4))]
pub struct BadStruct {
    foo: i32
}

fn main() {
    BadStruct { foo: 0 };
}

It's probably correct that this is an error, but it should not be an ICE. Also, the ICE only appears when the struct is actually instantiated, only defining it is not sufficient, but should also result in an error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.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