Skip to content

Commit 8bff059

Browse files
committed
added various points raised by people on the PR
1 parent 2ffdace commit 8bff059

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

active_discussion/representation.md

+19-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Introduction
44

5-
This discussion is meant to focus on two things:
5+
This discussion is meant to focus on the following things:
66

77
- What guarantees does Rust make regarding the layout of data structures?
88
- What guarantees does Rust make regarding ABI compatibility?
@@ -92,6 +92,8 @@ As an example, a value of `&T` type can never be null -- therefore,
9292
say that they will have the same layout?
9393
- or do we have the freedom to rearrange the types of `A` but not
9494
`B`, e.g. based on PGO results
95+
- What about different instantiations of the same struct? (`Vec<A>`
96+
vs `Vec<B>`)
9597
- Rust currently says that no single value may be larger than `isize` bytes
9698
- is this good? can it be changed? does it matter *here* anyway?
9799

@@ -102,6 +104,9 @@ To start, we will create threads for each major categories of types
102104

103105
- Integers and floating points
104106
- What about uninitialized values?
107+
- What about signaling NaN etc? ([Seems like a
108+
non-issue](https://github.com/rust-lang/rust/issues/40470#issuecomment-343803381),
109+
but it'd be good to resummarize the details).
105110
- Booleans
106111
- Prior discussions ([#46156][], [#46176][]) documented bool as a single
107112
byte that is either 0 or 1.
@@ -118,12 +123,25 @@ To start, we will create threads for each major categories of types
118123
(and/or treated by the ABI)?
119124
- e.g., what about different structs with same definition
120125
- across executions of the same program?
126+
- For example, [rkruppe
127+
writes](https://github.com/rust-rfcs/unsafe-code-guidelines/pull/5#discussion_r212776247)
128+
that we might "want to guarantee (some subset of) newtype
129+
unpacking and relegate repr(transparent) to being the way to
130+
guarantee to other crates that a type with private fields is and
131+
will remain a newtype?"
121132
- Tuples
122133
- Are these effectively anonymous structs?
123134
- Unions
124135
- Can we ever say anything about the initialized contents of a union?
125136
- Is `#[repr(C)]` meaningful on a union?
137+
- When (if ever) do we guarantee that all fields have the same address?
126138
- Fn pointers (`fn()`, `extern "C" fn()`)
139+
- When is transmuting from one `fn` type to another allowed?
140+
- Can you transmute from a `fn` to `usize` or raw pointer?
141+
- In theory this is platform dependent, and C certainly draws a
142+
distinction between `void*` and a function pointer, but are
143+
there any modern and/or realisic platforms where it is an
144+
issue?
127145
- References `&T` and `&mut T`
128146
- Out of scope: aliasing rules
129147
- We currently tell LLVM they are aligned and dereferenceable, have to justify that

0 commit comments

Comments
 (0)