How about add counted_by attribute for flexible-array?

Started by Japin Liover 1 year ago1 messages
#1Japin Li
japinli@hotmail.com

Hi, hackers

When I read [1]https://embeddedor.com/blog/2024/06/18/how-to-use-the-new-counted_by-attribute-in-c-and-linux/, I think the "counted_by" attribute may also be valuable for
PostgreSQL.

The 'counted_by' attribute is used on flexible array members. The argument for
the attribute is the name of the field member in the same structure holding
the count of elements in the flexible array. This information can be used to
improve the results of the array bound sanitizer and the
'__builtin_dynamic_object_size' builtin [2]https://reviews.llvm.org/D148381.

It was introduced in Clang-18 [3]https://godbolt.org/z/5qKsEhG8o and will soon be available in GCC-15.

[1]: https://embeddedor.com/blog/2024/06/18/how-to-use-the-new-counted_by-attribute-in-c-and-linux/
[2]: https://reviews.llvm.org/D148381
[3]: https://godbolt.org/z/5qKsEhG8o

--
Regrads,
Japin Li