Skip to content

Commit 76556a2

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

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/const_eval.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,12 @@ 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: if a byte has provenance but is not part of an adjacent group of bytes that form an entire pointer, compilation will fail.
237+
238+
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.
239+
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.
240+
235241
r[const-eval.const-context]
236242
## Const context
237243
[const context]: #const-context

0 commit comments

Comments
 (0)