> On Nov 14, 2025, at 09:36, Qing Zhao <[email protected]> wrote:
> 
> 
> 
>> On Nov 14, 2025, at 01:50, Martin Uecker <[email protected]> wrote:
>> 
>> Am Donnerstag, dem 13.11.2025 um 20:41 +0000 schrieb Qing Zhao:
>>> 
>>>> On Nov 13, 2025, at 14:17, Martin Uecker <[email protected]> wrote:
>>>> 
>>>> Am Donnerstag, dem 13.11.2025 um 15:44 +0000 schrieb Qing Zhao:
>>>> 
>>>>> 
>>> 
>> 
>> 
>>>> 
>>>>> 
>>>>>> 
>>>>>> You would then check correctness of the attribute only when the parent 
>>>>>> type is complete.
>>>>> 
>>>>> Okay.
>>>>>> 
>>>>>> If we want to support counted_by in even more generic cases,
>>>>> 
>>>>> What kind of more generic cases? Any example?
>>>> 
>>>> I was thinking about
>>>> 
>>>> struct bar {
>>>>  char *buf __counted_by(n);
>>>> };
>>>> 
>>>> struct foo {
>>>> int n;
>>>> struct bar;
>>>> };
>>>> 
>>>> which is allowed with -fms-extensions.
>>>> 
>>>> I don't think we should support this.
>>> 
>>> Don’t support this even when -fms-extensions is enabled?
>> 
>> Yes, because then you can't emit an error for
>> struct bar anymore (e.g. as the in the following example),
>> because we can't know whether it might be used later 
>> as an anonymous field where it could refer to some other 'n'.
>> 
>> struct bar {
>>  int m;
>>  char *buf __counted_by(n);
>> };
>> 
>> But I think an error would be useful here.
> 
> Okay, make sense to me.
> I will add this.

At the same time, shall we support the following with -fms-extensions:

/* -fms-extensions */

struct ids
{
  int length_ad;
  int length_na;
};

struct person
{
  int age;
  int weight;
  struct ids;    // Anonymous structure, no name needed
  char *address __attribute__ ((counted_by (length_ad)));
  char name[]  __attribute__ ((counted_by (length_na)));
} *Jim;

i.e, in the above, the counted_by fields for Pointer “address” and FAM “name” 
are in the anonymous 
structure “struct ids” which is not inlined into the “struct person”. 

Any idea on this?

Qing

> 
> Thanks a lot.
> 
> Qing
>> 
>> 
>> Martin


Reply via email to