https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122496
Bug ID: 122496
Summary: counted-by attribute is not supported correctly for a
FAM embedded in an anonymous structure
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: qinzhao at gcc dot gnu.org
Target Milestone: ---
for example:
#define __counted_by(member) \
__attribute__((__counted_by__(member)))
/* Only GCC complains. */
struct fam_in_struct {
int count;
struct {
char a;
char fam[] __counted_by(count);
};
};
[counted_by_bug]$ sh t
/home/opc/Install/latest-d/bin/gcc -O1 t1.c
t1.c:9:14: error: argument ‘count’ to the ‘counted_by’ attribute is not a field
declaration in the same structure as ‘fam’
9 | char fam[] __counted_by(count);
| ^~~