[clang] [Clang] Implement the 'counted_by' attribute (PR #76348)

Bill Wendling via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 22 12:39:56 PST 2024


bwendling wrote:

> @bwendling is there any plan / possibility for simple expressions (with no side effects)? Like:
> 
> ```c
> struct libusb_bos_dev_capability_descriptor {
> 	uint8_t  bLength;
> 	uint8_t  bDescriptorType;
> 	uint8_t  bDevCapabilityType;
> 	uint8_t  dev_capability_data[] __attribute__((counted_by(bLength - 3)));
> };
> ```

Not right now. Apple is in the process of expanding the bounds checking code beyond checking only flexible array members. We will most likely follow their lead on `constexpr`-like expressions. But the utility of such a feature would need to be explored.

https://github.com/llvm/llvm-project/pull/76348


More information about the cfe-commits mailing list