rust-lang / nomicon

The Dark Arts of Advanced and Unsafe Rust Programming
https://doc.rust-lang.org/nomicon/
Apache License 2.0
1.82k stars 263 forks source link

repr(int) enums: both size and sign matter #458

Closed RalfJung closed 1 month ago

RalfJung commented 2 months ago

The text makes it sound like only the size matters, but i32 and u32 are not ABI-compatible so we have to talk about size and sign here.

RalfJung commented 1 month ago

Might it also be a good idea to update https://github.com/rust-lang/reference/blob/72267820df5533a75505a81a97dba670334f0d57/src/type-layout.md#reprc-field-less-enums with the same wording?

Not sure -- that file is largely about the type's layout, which would not include the sign. The sign only matters for function call ABI. A file titled "type layout" seems like the wrong place to discuss that.