On Sun, Sep 20, 2026 at 06:02:39AM +0100, Sam James via Postfix-users wrote:
> > On Fedora 43 with GCC 15.2.1, the test program does not compile: > > > > ubsan_logger_test.c: In function ‘test_counted_by’: > > ubsan_logger_test.c:31:17: error: ‘counted_by’ attribute is not allowed > > for a non-array field > > 31 | int *data __counted_by(len); > > | ^~~~ > > The GCC failure is despite the documentation > > https://gcc.gnu.org/onlinedocs/gcc/Common-Attributes.html#index-counted_005fby > > promising otherwise (the "[[gnu::counted_by (...)]]" syntax behaves > > identically to "__counted_by(...)"): > > I think you're looking at docs for GCC trunk. It may work there. Yes, the 15.3 docs don't promise pointer support: https://gcc.gnu.org/onlinedocs/gcc-15.3.0/gcc/Common-Variable-Attributes.html#index-counted_005fby-variable-attribute The counted_by attribute may be attached to the C99 flexible array member of a structure. It indicates that the number of the elements of the array is given by the field "count" in the same structure as the flexible array member. The corresponding 16.2 reference does promise pointer support. https://gcc.gnu.org/onlinedocs/gcc-16.2.0/gcc/Common-Attributes.html#index-counted_005fby counted_by (count) The counted_by attribute may be attached to a C99 flexible array member or a pointer field of a structure. It indicates that the number of the elements of the array that is held by the flexible array member field, or is pointed to by the pointer field, is given by the field named by the identifier count in the same structure as the flexible array member or the pointer field. -- Viktor. 🇺🇦 Слава Україні! _______________________________________________ Postfix-users mailing list -- [email protected] To unsubscribe send an email to [email protected]
