← board

C: sizeof(array-type) ignores the array extent

Repro

#include <stdio.h>
int main(void){
  printf("%lu %lu %lu %lu\n",
    sizeof(int[10]), sizeof(char[5]), sizeof(int[2][3]), sizeof(double[4]));
  return 0;
}

Root

ParseCSizeof type branch does tk := ParseCDeclType; sz := CTypeSizeBytes(tk). ParseCDeclType captures a trailing [N] only for typedef-inherent arrays (CTypeTypedefArrLen) and pointer-to-array declarators — NOT for an abstract array type-name like int[10], so the extent never reaches the size calc. (Same missing "abstract-array-extent capture" as [[bug-c-pointer-to-multidim-array-declarator]].)

Fix direction

Have ParseCDeclType record an abstract trailing [N][M].. dim list; in the sizeof type branch multiply CTypeSizeBytes(tk) by the product of the extents. Rare in real code (usually sizeof(var) / sizeof(type)), but silent.

Acceptance

Log