- 
                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-writeup-assignedStatus: Ready for a writeup and someone is assigned to itStatus: Ready for a writeup and someone is assigned to it
Description
This issue is to discuss the memory layout for integral and floating point types:
- bool
- u8..- u128,- i8..- i128
- usize,- isize
- f32,- f64
For the most part, these are relatively uncontroversial. However, there are some interesting things worth discussing:
- Unlike other types, there are no #[repr(C)]vs#[repr(Rust)]variants here. The size is always fixed and well-defined across FFI boundaries. The types map to their corresponding integral types in the surrounding C ABI.
- Prior discussions ([#46156][], [#46176][]) documented bool as a single byte that is either 0 or 1.
- How is usizeintended to be defined on various platforms?- the native size of a pointer?
- the max of various other considerations?
- other edge cases to consider?
 
- Rust currently states that the maximum size of any single value must fit in with isize
 - Can we say a bit more about why? (e.g., ensuring that "pointer diff" is representable
- Do we want to discuss signaling NaN at all? Specifically: why is it potentially of concern, and are there things that unsafe authors or other folks need to be aware of? (@gankro, for example, wrote that "NaN masking is unnecessary from LLVM's perspective", but I don't really know what that means. =)
Metadata
Metadata
Assignees
Labels
A-layoutTopic: Related to data structure layout (`#[repr]`)Topic: Related to data structure layout (`#[repr]`)S-writeup-assignedStatus: Ready for a writeup and someone is assigned to itStatus: Ready for a writeup and someone is assigned to it