Skip to content

ICE: Struct cannot be packed and aligned #43317

Closed

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.

Activity

  1. added
    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
    on Jul 18, 2017
  2. bitshifter commented on Jul 22, 2017

    @bitshifter
    Contributor

    Interesting, if you change the repr to a one liner (playground) you get a compile error as expected (tested https://github.com/rust-lang/rust/blob/master/src/test/compile-fail/conflicting-repr-hints.rs#L30). I didn't realise that the behaviour would be different if the repr statements were split. I'll take a look.

  3. bitshifter commented on Jul 22, 2017

    @bitshifter
    Contributor

    The other compile fail tests in that file don't work if the representation hints are split also. I assume that's not a good thing.

  4. added a commit that references this issue on Jul 27, 2017
    52a3309
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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