https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116728
Bug ID: 116728 Summary: c23 tag compatibility broken with pointers to incomplete types Product: gcc Version: 14.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: himehaieto at gmail dot com Target Milestone: --- Created attachment 59117 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=59117&action=edit tag-compat-pointer-bug.i C23 changed struct tag compatibility rules to allow for structs with the same tag and multiple non-conflicting definitions to be compatible, and for incomplete types to be defined and established as compatible later in the translation unit. However, when the attached code attempts to use such an incomplete type for a function, the compiler instead gives the familiar pre-C23 error about incompatible types (i.e., "struct foo *" vs "struct foo *"). A forward declaration at the start (i.e., struct_foo;) and/or an inline definition of the struct within the function signature (i.e., void bar(struct foo {int value;} *foo) {}) allow the code to compile without issues, but in their absence it breaks. Note that this issue has a lot more potential subtlety with language lawyer standardese than it may seem at first, but I'm 95% sure that tag compatibility is supposed to allow for code like the attached to work now. See the below for additional reproducibility information. `uname -a`: Linux votocon 4.19.0-21-amd64 #1 SMP Debian 4.19.249-2 (2022-06-30) x86_64 GNU/Linux `lsb_release -a`: Distributor ID: Devuan Description: Devuan GNU/Linux 5 (daedalus) Release: 5 Codename: daedalus gcc configure options: ../../configure --prefix=/opt/gcc/14.2.0 --enable-lto compiler command/options: gcc --std=c23 tag-compat-pointer-bug.c