Skip to content

ICE: Struct cannot be packed and aligned #43317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Boddlnagg opened this issue Jul 18, 2017 · 2 comments
Closed

ICE: Struct cannot be packed and aligned #43317

Boddlnagg opened this issue Jul 18, 2017 · 2 comments
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@Boddlnagg
Copy link
Contributor

Boddlnagg commented Jul 18, 2017

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.

@sfackler sfackler added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jul 18, 2017
@bitshifter
Copy link
Contributor

bitshifter commented Jul 22, 2017

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.

@bitshifter
Copy link
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.

@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 22, 2017
bitshifter added a commit to bitshifter/rust that referenced this issue Jul 23, 2017
bors added a commit that referenced this issue Jul 27, 2017
Improve checking of conflicting packed and align representation hints on structs and unions.

Fixes #43317 and improves #33626.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

4 participants