-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Clarify whether #[repr(C)]
can be used on tuple structs or not.
#29526
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
Comments
It's well-defined; perhaps the docs aren't as clear as they could be. |
Just to be clear, tuples and structs are handled pretty much identically. There are two properties, named type and named fields that distinguish the 3 options:
In theory, there is no reason you couldn't apply |
/cc @rust-lang/lang, is this well-defined? I'm guessing so, but I'd like to be sure before I document it. |
I see no reason to disallow it. I vote "not a bug". |
Agree. Change to a docs bug? |
Sounds good, I'll document it. |
Until now I had the impression that it would be undefined how this construct would behave. The Rustonomicon implies that this is still the case, as tuple-structs are just like “named tuples”. On the other hand, the reference implies that it should be safe to use
#[repr(C)]
since tuple structs behave like normal structs with anonymous fields.I would appreciate if this would be clarified in the docs. If it is still undefined behavior
#[repr(C)]
on a tuple struct should cause an compiler error.The text was updated successfully, but these errors were encountered: