← board

C frontend: pointer-to-multidim-array declarator int (*p)[A][B] rejected

Repro

int gg[4][5][6][3];
int main(void){
  int (*p2)[6][3] = gg[2];   /* partial index, 1 of 4 -> int(*)[6][3] */
  p2[4][5][2] = 99;
  return gg[2][4][5][2];      /* 99 */
}

Relation to the partial-index fix

[[bug-c-partial-multidim-array-index]] (fixed de649c39) makes a partial multi-dim index produce the correct sub-array address for any number of remaining dims. But when >=2 dims remain (gg[2] -> int(*)[6][3]), there is no way to DECLARE the target pointer type, so the value is unusable. Single-remaining-dim partials (g[1][3] -> int(*)[7]) work end to end today. This ticket closes the >=2-dim gap.

Fix direction

Extend the C declarator parser to accept a bracket run after (*name): (*p)[A][B]... should record the full inner array shape (spans A,B,..) on the pointer symbol — generalise SymPtrElemArrLen to a dim list (as UFldArr* / SymArrDim* already do for arrays) so p[i][j][k] strides by the right sub-array sizes.

Acceptance

Log