https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120102
Bug ID: 120102 Summary: function prototype with array of forward declared struct is incomplete? Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: izaberina at gmail dot com Target Milestone: --- this code forward declares a struct and it's accepted: ``` struct foo; void f(struct foo *arg); ``` this version is rejected: ``` struct foo; void g(struct foo arg[]); ``` they are completely equivalent after adjustment of parameters, and of course it's possible to assign things between them: https://godbolt.org/z/4zr3YWhrP basically all versions of gcc and clang on godbolt accept the former and reject the latter. for whatever reason, msvc is cool with both: https://godbolt.org/z/fzPExThx7 the following is the relevant text from c17: > 6.7.6.3 Function declarators (including prototypes) > ... > 4. After adjustment, the parameters in a parameter type list in a function > declarator that is part of a definition of that function shall not have > incomplete type. > ... > 7. A declaration of a parameter as "array of type" shall be adjusted to > "qualified pointer to type", where the type qualifiers (if any) are those > specified within the [ and ] of the array type derivation. i do find it unlikely that both gcc and clang are wrong on this, but i really think both versions should be accepted, as they are equivalent. can some language lawyer chime in?