← board

C array element designators [i] = v + [] size inference from designators

Cases

Symptom

[idx] = designator ignored → sequential fill → wrong slots; and for [], size = element-count instead of max designated index + 1, so both values and sizeof are wrong.

Fix (a "current element index" cursor)

Before each element, if the stream is [ constexpr ] =, evaluate the index, set the running ei to it (consume [ ] =); else keep sequential ei. Track maxEi and, for an unsized [], set arrLen = maxEi + 1.

Gate

00092/00147 exit 0 (00148 needs struct designators too); drop from test/c-conformance/pxx.skip; regression test; make test + self-host.

Log