Skip to content

Commit 5b019ef

Browse files
committed
const-eval: explain the final-value-byte-provenance restriction
1 parent e8ba94e commit 5b019ef

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/const_eval.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,13 @@ r[const-eval.const-expr.loop]
232232
r[const-eval.const-expr.if-match]
233233
* [if] and [match] expressions.
234234

235+
r[const-eval.const-expr.final-value-provenance]
236+
The representation of the final value of a constant or static initializer must only contain provenance in whole-pointer groups:
237+
if a byte has provenance but is not part of an adjacent group of bytes that form an entire pointer, compilation will fail.
238+
239+
If a byte in the representation of the final value is uninitialized, then it *may* end up having provenance, which can cause compilation to fail.
240+
As a quality-of-implementation concern, the compiler should only actually fail if the initializer copies or overwrites parts of a pointer and that memory ends up in the final value.
241+
235242
r[const-eval.const-context]
236243
## Const context
237244
[const context]: #const-context

0 commit comments

Comments
 (0)