https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122495
Bug ID: 122495
Summary: counted_by is not supported correctly for a FAM in
union
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: ---
After FAM in union is supported, the counted_by attribute is not supported
correctly for it.
for example:
#define __counted_by(member) \
__attribute__((__counted_by__(member)))
/* Both Clang an GCC complain about this. */
struct fam_in_union {
int count;
union {
char a;
char fam[] __counted_by(count);
};
};
t.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);
| ^~~