From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 365083858032; Thu, 23 Feb 2023 09:10:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 365083858032 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677143409; bh=RFwpgcCOXRUyy0645qROieDT9c3o5zv/RaLpzYRjW+w=; h=From:To:Subject:Date:In-Reply-To:References:From; b=GaIAMRetqeL7aKKhxNx23iO32Ot6ygffrnPGQKW9galoneEw+TKiRrQHQ24DsfLfI fJuSlm1zdvQKW+VEmWeM5O9MxCx/WidwXQMm//1VYOUdCjkGLLRNWm+3KHNCdcUg1d swtRlLbjuZLd15snisoj49982sZi8GUNhnEIO/h4= From: "jakub at gcc dot gnu.org" 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, 23 Feb 2023 09:10:07 +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: jakub at gcc dot gnu.org 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 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #3 from Jakub Jelinek --- (In reply to Richard Biener from comment #2) > Iff only (GNU) C would accept the following ... >=20 > struct foo { > ... > unsigned int count; > ... > int data[count]; > }; Well, that I think conflicts with the variable length structures GNU extens= ion, where if the array size of a field isn't a constant expression, it is an expressi= on evaluated at runtime once (SAVE_EXPR) to determine the field size. Here we are talking about something similar to what Fortran wants with its deferred length arrays, essentially to have the size evaluated each time it= is accessed. With the data[count] form even if it would be disambiguated the question is= if we want to otherwise treat it like normal flexible array member e.g. for si= zeof etc. and only treat it specially for __bdos, or if it would affect say size= of too. I don't see how sizeof (struct foo) could be treated differently from flexi= ble array member, because one doesn't have an object on which count can be evaluated, but perhaps struct foo f; f.count =3D 24; sizeof (f.data) could change.=