Skip to content

Commit 3404252

Browse files
committed
Add note explaining whole-pointer order requirement
Let's add an admonition explaining that bytes with provenance must form a complete pointer in the correct order.
1 parent cfad08e commit 3404252

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/const_eval.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,11 @@ const C: Pair = unsafe {
260260
};
261261
```
262262

263+
> [!NOTE]
264+
> The bytes with provenance must form a complete pointer in the correct order. In the example above, the pointer is written at offset 20, but a pointer requires 8 bytes (assuming an 8-byte pointer). Four of those bytes fit in the `y` field; the rest extend into the padding at offset 24. When the fields are initialized, the `y` bytes get overwritten, leaving only a partial pointer (4 bytes) in the padding. These 4 bytes have provenance but don't form a complete pointer, causing compilation to fail.
265+
>
266+
> This restriction ensures that any bytes with provenance in the final value represent complete pointers. Binary formats such as ELF cannot represent pointer fragments, so the compiler cannot emit them in the final binary.
267+
263268
> [!NOTE]
264269
> Manually initializing (e.g., zeroing) the padding bytes ensures the final value is accepted:
265270
>

0 commit comments

Comments
 (0)