Repository navigation
D198 (§16.2b.5): the draft states reads, fills and updates param N from proofs; a drafted value record is flat - #3216
Merged
Merged
Conversation
added 2 commits
November 9, 2026 22:30
… N` from proofs over the library's source A draft states a value-record clause only when everything it depends on is read (D198). CImport.w records how each body uses a pointer parameter (ci_value_record_evidence): a write through it, a read through it, the parameter passed on, and anything that leaves the one record or keeps a pointer (an index, pointer arithmetic, the address of a part, a copy, a store, a return). The scan records where each record is complete, and `with get` keeps those a header the package installs defines. CiFacadeDraft.w draws the records with identity (some function produces, destroys or retains a pointer to one: zlib's z_stream) and gives a parameter its word (fd_value_record_word): the record is complete in an installed header and has no identity; the body keeps no pointer to it or into it and touches only the one record; it is passed on only to package functions the same holds for. `const T *` is `reads`; `T *` written and never read is `fills`; any other `T *` is `updates`. The clause is written in the function's item with its proof; an operation over value records alone states no `lend`. The report says 'value records: reads param 0 (proof: …)' and, for a record pointer left raw, which condition failed. The survey tool clusters that reason. Fixture: conan_facade_value_record_draft_test (each word; an indexed array, a part's address, a retained pointer and a record with identity stay raw).
A record with a pointer in it is not one record to the callee: freetype's FT_Outline_Get_CBox(const FT_Outline *) follows `outline->points`, and whoever builds the record chooses where that points, so presenting it as `&FT_Outline` would let a safe call read arbitrary memory. The body evidence saw only a read through the parameter. The draft now states a clause only for a record that is complete in an installed header and flat: arithmetic types and enums, fixed arrays of such, and defined records made only of such (ci_type_is_flat). A hand-written facade's clause remains the author's assertion (§16.2b.5); this is the limit of what a draft can prove. The report's reason reads '<Record> is not a flat record complete in a header the package installs (it holds a pointer, or is opaque there)'. Fixture: span_first (a record holding a pointer stays raw).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The drafter half of spec v7.43's 'Value records' (D198, #3173):
with getwrites the clauses itself, from proofs over the library's source. Two commits.A clause is stated only when everything it depends on is read: the record is flat (no pointer anywhere inside it) and complete in a header the package installs; no function of the package produces, destroys or retains a pointer to that record type; the body keeps no pointer to the record or into it, touches only the one record (no index, no arithmetic, no part's address, no copy of the pointer), and passes it on only to package functions the same holds for.
const T *isreads;T *written and never read isfills; any otherT *isupdates.The flat rule is a safety condition beyond the spec's words, found on freetype (
FT_Outline_Get_CBoxfollowsoutline->points); it is in the drafter only and surfaced to Eric on #3173.The report says 'value records: reads param 0 (proof: …)' or, for a record pointer left raw, which condition failed; the survey tool clusters that reason.
Checked end to end: the facade block the drafter wrote for the fixture's library compiles and runs as a program (
12 20 40 4 5).Fixture: conan_facade_value_record_draft_test. Battery GREEN on 4bc10be (
with run tools/battery.win ~/.local/with-staging/vdraft, wall 448 s after a green gate and internals lane; GREEN BATTERY_DONE).