From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7A2453858C83; Wed, 8 Mar 2023 20:20:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7A2453858C83 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678306843; bh=KoLoRRr9Hy+1rp27EjNQ33htv3nY5TIYwFGsLJPRhLg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=r2v2r02qnBaZfoYIeh5fwvnuWhEWpJKHkVJTMEwSHVffaDHcYliP7E3KoY7zXu7Ht mXsJ0jg44wYUBeSGCPSxwre9w8UpS9dF/dhCRc7nqYI/zU1YeJYMOdvCO+FevOE7Tq j1+Z0PC4o2rvLGxVVzHUaFOtPOICD2ZTijNOA8/Y= 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: Wed, 08 Mar 2023 20:20:43 +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 #32 from Martin Uecker --- Am Mittwoch, dem 08.03.2023 um 19:20 +0000 schrieb qinzhao at gcc dot gnu.o= rg: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108896 >=20 > --- Comment #30 from qinzhao at gcc dot gnu.org --- > (In reply to Martin Uecker from comment #28) >=20 > > The problems with VLA are in my opinion caused by poor > > implementation (e.g. no stack probing etc) and bad > > code generation (Linus was not happy about this) and > > not because anything is fundamentally bad about them > > from the point of language semantics. >=20 > you mean gcc's implementation? how about other compilers? I mostly mean compilers without stack probing (which GCC has but is not activated by default). Code quality is probably still bad for most compilers. >=20 > > VM =3D variably modified. In C it is a type which is derived from > > a VLA which is not necessarily itself a VLA, e.g. a pointer to > > a VLA. But a VLA is also a VM type. >=20 > Okay. > >=20 > > > struct foo { > > > =C2=A0=C2=A0int len; > > > =C2=A0=C2=A0char (*buf)[.len]; > > > }; > > >=20 > > >=20 > > > This has less issues because the size of the struct then does not dep= end > > > on the length. >=20 > but I am still not clear on why "the size of the above struct 'foo' does = not > depend on the .len?" in my opinion, it should depend on .len. do I miss > anything here? Here the last element is not a flexible array member but a pointer to an array of size len. The size of the pointer is fixed. Martin >=