Skip to content

Should char have the same layout as u32? #462

Closed
@djkoloski

Description

@djkoloski

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-layoutTopic: Related to data structure layout (`#[repr]`)S-not-opsemDespite being in this repo, this is not primarily a T-opsem questionT-lang

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions