From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6898B3858C54; Thu, 2 Mar 2023 18:34:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6898B3858C54 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677782087; bh=0zBxgmzyN7/2UsMmuGZHovuWZB/eKgyLOFBfDrwX6s0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=vKs00lpp6d/R8e0aM/MfaRyZkfQAT75SsosiU9rcyqmakWwPQgAlZHdcz0Aq+leLV PAfpof9MPeJgOx4O32G7aWvZX+LbTsphq20Z6QEdtAFRu8UU4R3DbeY1uGhd5CXGN0 aXnDYvwjp2H93dWzAKLOobXuVY8rgP3xFPmuK83E= From: "muecker at gwdg dot de" 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: Thu, 02 Mar 2023 18:34:47 +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: muecker at gwdg dot de 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: 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 --- Comment #10 from Martin Uecker --- And to get bounds checking for the flexible array member today, one could use a macro to attach the bound back to the array on member access. https://godbolt.org/z/GbaoYrhav But the bound from the type is not fed back into __builtin_dynamic_object_size(), so this currently only helps for direct array refs. But this is something we may be able to improve.=