> On Jun 11, 2025, at 15:45, Joseph Myers <josmy...@redhat.com> wrote: > > On Wed, 11 Jun 2025, Qing Zhao wrote: > >> When I was adding more testing cases for the pointee type being >> structure/union, I have a question for the following case: >> >> struct item5 { >> int a; >> float b[]; >> }; >> >> struct pointer_array_9 { >> ... >> int count5; >> struct item5 *array_5 __attribute__ ((counted_by (count5))); >> }; >> >> In the above, “struct item5” is a structure type with flexible array >> member, whose size is not know during compilation time, as a result, the >> size of the whole structure is unknown during compilation time, shall we >> reject such cases? > > Since the standard doesn't allow a structure with a flexible array member > (or a union containing such a structure, recursively) to be an element of > an array, it seems reasonable to reject such cases as well.
Okay. I will do that. Then how about the following case: typedef struct item3 Item3; struct pointer_array_9 { int count3; Item3 *array_3 __attribute__ ((counted_by (count3))); } struct item3 { int a; float b[]; } In the above, the “Item3” is an incomplete type inside “struct pointer_array_9”, whose definition is given afterward. Theoretically, C FE should issue error for the above counted_by attribute. However, when and how should we Implement this in C FE: when we examine the counted_by attribute for “array_3” inside “struct pointer_array_9”, there is no any information on the TYPE of “Item3” yet, only when we see the definition of “struct item3” afterward, we know that this structure includes a FAM, the previous “counted_by” attribute should not be added for “array_3”. Is there a way to trace back to “struct pointer_array_9” when the definition of “struct item3” is parsed? When should we issue error for such case? Thanks. Qing > > -- > Joseph S. Myers > josmy...@redhat.com