From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6AFAC3858438; Wed, 27 Dec 2023 06:31:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6AFAC3858438 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1703658666; bh=38v5v7OEYb04jgCLURIA/Hx8VhjslO37DVlanm3N3Rc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=MJsic9fd5zhIT6M0OZvtlb7q/xg8m++1zFObyOAYgZsDutwIKzPA0p8b/O2VPJZq4 2dDP61Cgc22ijCdNv/M2pFUGEiumVkh00dQmPsBptxcAZdIDLrzSx27SbUVDBOUyzr jqNBVsh1a7qmxZXLIiLkPXg59T1KQ2giB23sijuo= From: "sean@rogue-research.com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/108896] provide "element_count" attribute to give more context to __builtin_dynamic_object_size() and -fsanitize=bounds Date: Wed, 27 Dec 2023 06:31:00 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: sean@rogue-research.com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: qinzhao at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108896 Sean changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |sean@rogue-research.com --- Comment #49 from Sean --- >>will you support expressions: >> >>struct P { >> int k; >> int x[.k * 4]; >>} >=20 >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__(bLe= ngth - 3))); See https://github.com/libusb/libusb/blob/37dee8f9dd429558e4d5bc4a804ab586abe72= 62a/libusb/libusb.h#L859C1-L859C51=