← board

C99 designated initializers + compound literals unsupported

Problem

Three related C99 initializer forms all fail to parse with expected C expression:

1. Designated struct-field initializers:

struct Point { int x, y, z; };
struct Point p = { .y = 5, .x = 1, .z = 9 };   /* order-independent, by name */

2. Designated array-index initializers:

int arr[5] = { [2] = 7, [4] = 9 };             /* sparse, by index */

3. Compound literals:

int total = sum((struct Point){ 3, 4 });       /* anonymous struct value */
int *p = (int[]){ 1, 2, 3 };                   /* anonymous array value */

All three are ordinary, reasonably common C99 constructs (designated initializers especially so — they're idiomatic for sparse tables, opt-in struct fields, and self-documenting initialization order). None currently parse; each is a separate expected C expression error at the .field = / [idx] = / (Type){...} token.

Scope

Plain brace-list initializers ({ 1, 2, 3 }, nested { {1,2}, {3,4} }) and static/global initializer lists already work elsewhere in the test suite — this ticket is specifically the three designator/compound-literal forms above.

Acceptance

Log

RESOLVED 2026-07-09 — array compound literals landed

(int[]){1,2,3} / (elem[N]){...} implemented (CParseCompoundLiteralArr + the cast- branch abstract-array declarator + AN_INDEX-over-array-CL IR case). Both acceptance repros pass (record sum((struct Point){3,4})==7 done earlier; array (int[]){1,2,3} via pointer/arg/direct-index all gcc-verified, b226). All three original forms (designated struct-field, designated array-index, compound literals — record AND array) are done. Only unsupported edge left: STRUCT-element array literals with nested braces (struct P[]){{1,2},{3,4}} (errors cleanly, no miscompile) — a rare extension, not filed separately. Conformance 220/220. RESOLVED — moving to done.