https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119585
Bug ID: 119585 Summary: counted_by in redefined structs. Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: uecker at gcc dot gnu.org Target Milestone: --- I think it would be useful if we allowed redefinitions of struct that add counted_by. This would allow enhancing a struct declared in a header later: struct foo { int n; char buf[]; }; // some header outside of my control struct foo { int n; [[gnu::counted_by(n)]] char buf[]; }; // my code Currently we are very strict in not allowing this, but this case (in contrast to inconsistent counted_by attributes which should still be rejected) seems safe and useful. https://godbolt.org/z/zjcq16Exd