https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110910
Bug ID: 110910 Summary: weakref should allow incomplete array type Product: gcc Version: 13.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: jrtc27 at jrtc27 dot com Target Milestone: --- Consider: extern char foo[]; static char weak_foo[] __attribute__((weakref("foo"))); Normally, being a tentative type with internal linkage, weak_foo would not be allowed to have an incomplete type, and this is what GCC enforces today ("warning: array 'weak_foo' assumed to have one element" / "error: array size missing in 'weak_foo'" depending on -pedantic). However, weakref is special, and makes weak_foo not exist at all, but instead be an alias for foo, which can legitimately have internal linkage. Therefore I believe this restriction, namely C99 6.9.2p3, should be relaxed when weakref is used. This does mean the diagnostic for something like: static char weak_foo[]; ... static char weak_foo[] __attribute__((weakref("foo"))); needs to be delayed until the whole file has been parsed, but given GCC already supports: static char foo[]; ... static char foo[42]; as an extension that doesn't seem to be a problem.