-
Notifications
You must be signed in to change notification settings - Fork 61
Closed
Labels
A-layoutTopic: Related to data structure layout (`#[repr]`)Topic: Related to data structure layout (`#[repr]`)S-not-opsemDespite being in this repo, this is not primarily a T-opsem questionDespite being in this repo, this is not primarily a T-opsem questionT-lang
Description
I'd like to be able to make the assumption that char is ABI compatible with u32 for some validation code in bytecheck. I have actually been making this assumption for a while and never had problems (including with MIRI), so I think this is de-facto the case. I thought that char and u32 were supposed to have the same layout but when I went looking I realized I couldn't find anything. As far as I know, it doesn't really make sense for chars to be anything other than a u32 with fewer valid bit patterns.
For completeness:
- "The Rust Reference: Type layout": States that both
u32andcharare four bytes. - "The Rust Reference: Textual types": States that it "is a Unicode scalar value (i.e. a code point that is not a surrogate), represented as a 32-bit unsigned word in the 0x0000 to 0xD7FF or 0xE000 to 0x10FFFF range.". I don't think this can be interpreted as having the same ABI as
u32.
Metadata
Metadata
Assignees
Labels
A-layoutTopic: Related to data structure layout (`#[repr]`)Topic: Related to data structure layout (`#[repr]`)S-not-opsemDespite being in this repo, this is not primarily a T-opsem questionDespite being in this repo, this is not primarily a T-opsem questionT-lang