From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id ED1FA385802D; Fri, 22 Jul 2022 22:33:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ED1FA385802D From: "isanbard at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/101836] __builtin_object_size(P->M, 1) where M is an array and the last member of a struct fails Date: Fri, 22 Jul 2022 22:33:55 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: isanbard at gmail dot com X-Bugzilla-Status: NEW 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Jul 2022 22:33:56 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101836 Bill Wendling changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |isanbard at gmail dot com --- Comment #40 from Bill Wendling --- (In reply to James Y Knight from comment #36) > (In reply to Kees Cook from comment #34) > > > Great. Adding that flag, and eliminating the -fstrict-flex-arrays=3D3= option > > > from this proposal would be good. > >=20 > > Hmm? No, -fstrict-flex-arrays=3D3 is still needed (because it changes c= ompiler > > _behavior_, e.g. for proper FORTIFY coverage or trailing arrays, etc). >=20 > There is no purpose served by writing a struct member `int x[0];` other t= han > to create a FAM. Zero-length arrays are not permitted by the C standard, = but > are a GCC compiler extension explicitly for the purpose of creating a FAM. > This is entirely unlike `int x[1];` or `int x[10];` which of course have a > primary meaning as a concrete array size... >=20 > If the linux kernel doesn't want to allow `int x[0];` FAMs, then prohibit > them entirely using -Werror=3Dzero-length-array (once it's implemented). [Kees, correct me if I'm wrong.] I don't think this satisfies what Kees initially asked for. The GCC extensi= on that a trailing `[0]' array in a structure is causing FORTIFY to fail. It w= ould be great to remove them all, but that's more-or-less a separate issue from making FORTIFY work in all instances. (From what I understand, removing the trailing `[0]' from Linux is an ongoing project.) The question then is if `-fstrict-flex-arrays=3D3' is used, what does a `[0= ]' at the end of a struct represent (assuming GCC no longer treats it as an FAM)?=