From 91d42d28ab7b0a816ba284e8c3685e03136a3f6f Mon Sep 17 00:00:00 2001 From: Hojun-Cho Date: Thu, 4 Jun 2026 02:38:36 +0900 Subject: [PATCH] test/800: pin >6-element 32B-struct append growth (#34 review, getopt OOB shape) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit getopt's deleted appendoption helper fed rt_ensure a hardcoded membsz=24, stale since str went 24B (option {rune,str} = 32B): the 8-slot first grow allocated 192B while writes strode 32 — OOB past 6 options. The builtin derives 32 from the type table (MOVQ $32, SI); this row appends 8 option literals and reads element 7 back full-width so the class stays pinned. No in-tree test parsed >3 options. --- test/wcc/800_append_wide_elem.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/wcc/800_append_wide_elem.c b/test/wcc/800_append_wide_elem.c index 2e432237..d7036e68 100644 --- a/test/wcc/800_append_wide_elem.c +++ b/test/wcc/800_append_wide_elem.c @@ -63,6 +63,15 @@ * tagged_ident_src | append of ALREADY-TAGGED locals | 42 * | (i64 + bool members) — the widener's | * | already-tagged source path. | + * struct_eight_appends | 8 struct-lit appends of the getopt | 15 + * | option shape ({rune,str} = 32B), | + * | full-width readback of element 7 — | + * | the >6-element OOB regression pin | + * | (getopt's deleted helper fed a stale | + * | hardcoded membsz=24: 8-slot grow was | + * | 192B while writes strode 32; the | + * | builtin derives 32 from the type | + * | table, MOVQ $32, SI). | * struct_call_loudstop | append(xs, f()) struct-from-call is | BUILD_FAIL * | the deferred source shape — must | * | fail LOUD on both stages (rule-7), | @@ -281,6 +290,23 @@ static const struct row rows[] = { "};\n", 42 }, + { "struct_eight_appends", + "package main;\n" + "type option = struct { flag: rune, value: str };\n" + "export fn main() i32 = {\n" + "\tlet opts: []option = [];\n" + "\tappend(opts, option { flag = 'a', value = \"v0\" });\n" + "\tappend(opts, option { flag = 'b', value = \"v1\" });\n" + "\tappend(opts, option { flag = 'c', value = \"v2\" });\n" + "\tappend(opts, option { flag = 'd', value = \"v3\" });\n" + "\tappend(opts, option { flag = 'e', value = \"v4\" });\n" + "\tappend(opts, option { flag = 'f', value = \"v5\" });\n" + "\tappend(opts, option { flag = 'g', value = \"v6\" });\n" + "\tappend(opts, option { flag = 'h', value = \"seventh\" });\n" + "\treturn (opts[7].value.len + opts.len): i32;\n" + "};\n", + 15 }, + { "struct_call_loudstop", "package main;\n" "type pt = struct { x: i32, y: i32, z: i64 };\n"