commit 45d32e2eacd778102210685d5b180367f5894da9
parent 70d7ac3b3443aaf7afc32adeb979cbcfd4953444
Author: Ryan Sepassi <rsepassi@gmail.com>
Date: Wed, 10 Jun 2026 08:28:54 -0700
doc(TODO): record I.2 initializer-walker divergence analysis
The two §6.7.9 walkers look parallel but diverge at load-bearing points
(gap-fill emit-zero vs rely-on-prezero, static compound-literal prologue,
struct iteration, value leaves). Document the hazards so any future
unification is scoped as its own heavily-tested change rather than folded
in opportunistically.
Diffstat:
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/doc/plan/TODO.md b/doc/plan/TODO.md
@@ -89,8 +89,19 @@ Add new deferred fixes below as they are discovered.
(`cc_default_obj_path_for_name`, `cc_dep_default_target`, `build_default_obj_name`); its
home is the driver util layer (`driver/`), not `link_inputs.c`. (The link pipeline +
flag-parse blocks were assessed and are not byte-identical — different option structs.)
-- **I.2 — two parallel C-6.7.9 initializer walkers** (`lang/c/parse/parse_init.c:648-777`)
- re-encode the same traversal grammar. Factor a single grammar driver + leaf vtable.
+- **I.2 — two parallel C-6.7.9 initializer walkers** (`init_at` runtime ~648-777;
+ `parse_static_init_at` static ~1419-1612 in `lang/c/parse/parse_init.c`) share the
+ array/struct/union/scalar traversal grammar (and already share `parse_designator_chain`
+ / `designator_continues_inside`) but diverge at load-bearing points that make a naive
+ merge a §6.7.9 miscompile risk: (1) GAP FILL — runtime emits explicit zero-stores for
+ array/designator gaps + unwritten struct fields (`zero_init_at` / `zero_object_bytes_at`),
+ static relies on the pre-zeroed output buffer and emits nothing; (2) a static-only
+ compound-literal cast-strip prologue; (3) struct iteration (runtime delegates to the
+ shared `init_struct_fields`, static inlines its own field loop); (4) the value leaves
+ differ (`parse_assign_expr`+`pcg_store` vs `parse_static_const`+encode; `init_string_at`
+ vs `parse_static_string_at`; bitfield leaves). A real unification needs a grammar driver
+ + a leaf vtable {scalar, string, bitfield, gap-fill, context=slot|buf}; treat it as its
+ own heavily-tested change, not an opportunistic dedup.
- **I.4 — two opt walks still hand-roll operand iteration that the central
`opt_walk_inst_operands` cannot express.** `reg_define_inst_defs` (pass_ssa) needs a
per-def index + version-stack (`pushed`) context, and `opt_collect_inst_uses`