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

other-reprs: do not make it sound like we are making ABI promises for repr(int) enums #461

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

RalfJung
Copy link
Member

Until something like rust-lang/rust#128600 lands, let's be careful what we say about this.

Also mention that repr(C) generally makes this behave the same as C ABI-wise. That's anyway what people already assume this means and are relying on in practice, so there's no point in not saying it IMO?

Cc @rust-lang/opsem @chorman0773

Copy link

@CAD97 CAD97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a note for review, otherwise 👍 from me

knowledge of "invalid" values at this type to optimize enum layout, such as when
this enum is wrapped in `Option`). Note that the function call ABI for these
types is still in general unspecified, except that across `extern "C"` calls they
are ABI-compatible with C enums of the same sign and size.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to point this out here as well, C has non-transitive rules that allow enum and the underlying integer type to be punned by ABI.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I saw that comment in the issue. I don't think that's something to discuss here though -- they key point is that the Rust thing matches the C thing.

Non-transitive compatibility doesn't really make sense IMO but that's a discussion for another day.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've run into problems with cfi tags on methods involving enums in the signature. You probably want to be careful about what you promise here. Unfortunately I don't know what the precise rules are CFI wise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants