Skip to content
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

#[repr(u64)], #[repr(C, u64)], #[repr(u64, C)] have different behavior #34622

Closed
lambda-fairy opened this issue Jul 3, 2016 · 0 comments
Closed
Labels
A-typesystem Area: The type system

Comments

@lambda-fairy
Copy link
Contributor

Code

use std::mem;

#[repr(u64)]
enum BookHorses { TwilightSparkle }

#[repr(C, u64)]
enum PurpleHorses { TwilightSparkle }

#[repr(u64, C)]
enum PrincessHorses { TwilightSparkle }

fn main() {
    println!("{}", mem::size_of::<BookHorses>());
    println!("{}", mem::size_of::<PurpleHorses>());
    println!("{}", mem::size_of::<PrincessHorses>());
}

Output

8
4
8

i.e. when the compiler sees multiple repr arguments, it takes the first one and ignores the rest.

Expected behavior

Either all enums should have the same size, or the latter enums should not compile.

lambda-fairy added a commit to lambda-fairy/gensokyo that referenced this issue Jul 3, 2016
@brson brson added I-wrong A-typesystem Area: The type system labels Jul 8, 2016
bors added a commit that referenced this issue Aug 31, 2016
Warn about multiple conflicting #[repr] hints

Closes #34622
mayah pushed a commit to mayah/x86intrin that referenced this issue Sep 9, 2016
Using multiple arguments to #[repr] does not work as we expected.
See: rust-lang/rust#34622
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-typesystem Area: The type system
Projects
None yet
Development

No branches or pull requests

2 participants