Authors: Grant Jurgensen
Date: 2026-08-25
Submitted against: C23
Status: Open
Consider the two array objects x and y with the following
declarations:
int x[] = {0, 1};
int y[] = {0, 1, 2};
Are the types of x and y compatible? My strict reading of C23
suggests they would be. 6.7.7.3 paragraph 6 says:
For two array types to be compatible, [...] if both size specifiers are present, and are integer constant expressions, then both size specifiers shall have the same constant value.
I interpret "size specifiers are present" and especially "are integer constant expressions" as syntactic claims. While sizes of both array types have been determined by the initializer (6.7.11 paragraph 23), neither are provided syntactically and therefore would not seem to be "present".
However, this interpretation conflicts with existing implementations. GCC, Clang, and CompCert all indicate that the two types are incompatible, citing their differences in size (i.e. number of elements).