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

Sean <s...@rogue-research.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |s...@rogue-research.com

--- Comment #49 from Sean <s...@rogue-research.com> ---
>>will you support expressions:
>>
>>struct P {
>>  int k;
>>  int x[.k * 4];
>>}
> 
>Maybe the size expressions should be limited to very simple
>expressions without side effects.

Simple expressions without side effects would be useful for libusb, whose
public API has structures like:

struct libusb_bos_dev_capability_descriptor {
        /** Size of this descriptor (in bytes) */
        uint8_t  bLength;

        uint8_t  other1;
        uint8_t  other2;

        /** Device Capability data (bLength - 3 bytes) */
        uint8_t  dev_capability_data[];
};

Here it seems we'd want to tag it with __attribute__((__element_count__(bLength
- 3)));

See
https://github.com/libusb/libusb/blob/37dee8f9dd429558e4d5bc4a804ab586abe7262a/libusb/libusb.h#L859C1-L859C51

Reply via email to