public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/112761] New: Using incomplete array types in function prototypes doesn't work
@ 2023-11-29 10:49 ville.syrjala at linux dot intel.com
2023-11-29 11:10 ` [Bug c/112761] " schwab@linux-m68k.org
0 siblings, 1 reply; 2+ messages in thread
From: ville.syrjala at linux dot intel.com @ 2023-11-29 10:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112761
Bug ID: 112761
Summary: Using incomplete array types in function prototypes
doesn't work
Product: gcc
Version: 13.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: ville.syrjala at linux dot intel.com
Target Milestone: ---
struct foo;
void func(struct foo bar[]);
int main(void)
{
}
error: array type has incomplete element type ‘struct foo’
3 | void func(struct foo bar[]);
| ^~~
This prevents using the array syntax in function prototypes with opaque types.
So I have to give up either:
- the array syntax, which means there is no longer any hint to the reader
whether the function takes an array or a pointer to a single object
- or the opaque type which is even worse since the clean abstraction is ruined
(not to mention the resulting stable ABI issues).
I couldn't immediately find anything in the spec that says this is illegal:
- "6.7.6.2 Array declarators ...
If the size is not present, the array type is an incomplete type."
- "6.7.6.3 Function declarators ...
If the function declarator is not part of a definition of that function,
parameters may have incomplete type and may use the [*] notation in their
sequences of declarator specifiers to specify variable length array types."
But maybe I just don't know how to read the spec correctly?
Side note:
This also affects the (arguably hideous) "ptr[static 1]" syntax which would be
beneficial to indicate that you can't pass in a null pointer. But I suppose
that one is explicitly forbidden by the spec since we do specify a size for the
"array" and thus it is not allowed to be an incomplete type.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c/112761] Using incomplete array types in function prototypes doesn't work
2023-11-29 10:49 [Bug c/112761] New: Using incomplete array types in function prototypes doesn't work ville.syrjala at linux dot intel.com
@ 2023-11-29 11:10 ` schwab@linux-m68k.org
0 siblings, 0 replies; 2+ messages in thread
From: schwab@linux-m68k.org @ 2023-11-29 11:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112761
Andreas Schwab <schwab@linux-m68k.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #1 from Andreas Schwab <schwab@linux-m68k.org> ---
6.7.6.2#1 ... The element type shall not be an incomplete or function type.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-11-29 11:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-29 10:49 [Bug c/112761] New: Using incomplete array types in function prototypes doesn't work ville.syrjala at linux dot intel.com
2023-11-29 11:10 ` [Bug c/112761] " schwab@linux-m68k.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).