https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116016

--- Comment #29 from qinzhao at gcc dot gnu.org ---
(In reply to Jakub Jelinek from comment #28)
> It would need to be a FE keyword where __builtin_get_counted_by would return
> some pointer, either e.g. (void *)0 if it doesn't have a count, or a pointer
> to the count (with type of the pointer dependent on what type the count has).

So, a RID_BUILTIN (i.e, FE keyword) like the following:

  (void *) __builtin_get_counted_by (ptr)

Then the user source code becomes the following:

If (__builtin_get_counted_by (P->FAM))
  *__builtin_get_counted_by (P->FAM) = COUNT;

> 
> Speaking of counted_by, I see support for it in c-family/ and c/, but not in
> cp/ at all, what is the attribute supposed to do in C++?
The initial plan is to support it in both C and C++ (since C++ can use flexible
array member too through GCC extension), but I didn't implement it in C++ in
the initial patch. 
> If it isn't supported, it should be documented that it doesn't apply to C++
> and should be rejected in C++.  If it is to be supported, the support
> (including support for templates) needs to be there before GCC 15.
I will try to support it in C++ too in GCC15. If not, I will update the
documentation to indicate this limitation.

Reply via email to