From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 7774C3858C50; Fri, 2 Dec 2022 07:16:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7774C3858C50 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 6BA1521B88; Fri, 2 Dec 2022 07:16:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1669965391; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=YNybiiYKqmgD0ZvAA2ERQbrmjUUSHBAIo+Ex0hUEV9c=; b=nPAgddc9QnoJYc0pcNzUnwbyR3JsS7oAz8vgDZwuGqSUu97Obvmah+PSd5OhEH0yvgwJ+m 65+13hBJDkuN21kQWB/uOMdSjprkFkLQxsSycISZ72R45vYAdSuFUu5Eb/NXzdYMdubt+s zdmXUQNcx3r9G96BUJag0a8py80MUpY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1669965391; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=YNybiiYKqmgD0ZvAA2ERQbrmjUUSHBAIo+Ex0hUEV9c=; b=9efyy+DqxXpx4sM5x9uHIZ9c4moBl1Q3SJLpRorpjD+QjfPlugWz7cpcbgoh8HK50lZNow 7d9swU6+vbV/3WBQ== Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 3E6F82C141; Fri, 2 Dec 2022 07:16:31 +0000 (UTC) Date: Fri, 2 Dec 2022 07:16:31 +0000 (UTC) From: Richard Biener To: Siddhesh Poyarekar cc: Kees Cook , Qing Zhao , joseph@codesourcery.com, gcc-patches@gcc.gnu.org, siddhesh@gcc.gnu.org Subject: Re: [V2][PATCH 1/1] Add a new warning option -Wstrict-flex-arrays. In-Reply-To: <898dfeed-f392-fb86-7fbd-f99d335c7a64@gotplt.org> Message-ID: References: <20221130142556.3079865-1-qing.zhao@oracle.com> <20221130142556.3079865-2-qing.zhao@oracle.com> <202212010840.C963E72661@keescook> <898dfeed-f392-fb86-7fbd-f99d335c7a64@gotplt.org> User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Thu, 1 Dec 2022, Siddhesh Poyarekar wrote: > On 2022-12-01 11:42, Kees Cook wrote: > > On Wed, Nov 30, 2022 at 02:25:56PM +0000, Qing Zhao wrote: > >> '-Wstrict-flex-arrays' > >> Warn about inproper usages of flexible array members according to > >> the LEVEL of the 'strict_flex_array (LEVEL)' attribute attached to > >> the trailing array field of a structure if it's available, > >> otherwise according to the LEVEL of the option > >> '-fstrict-flex-arrays=LEVEL'. > >> > >> This option is effective only when LEVEL is bigger than 0. > >> Otherwise, it will be ignored with a warning. > >> > >> when LEVEL=1, warnings will be issued for a trailing array > >> reference of a structure that have 2 or more elements if the > >> trailing array is referenced as a flexible array member. > >> > >> when LEVEL=2, in addition to LEVEL=1, additional warnings will be > >> issued for a trailing one-element array reference of a structure if > >> the array is referenced as a flexible array member. > >> > >> when LEVEL=3, in addition to LEVEL=2, additional warnings will be > >> issued for a trailing zero-length array reference of a structure if > >> the array is referenced as a flexible array member. > >> > >> At the same time, -Warray-bounds is updated: > > > > Why is there both -Wstrict-flex-arrays and -Warray-bounds? I thought > > only the latter was going to exist? Sorry for appearantly not being clear - I was requesting -Wstrict-flex-arrays to be dropped and instead adjusting -Warray-bounds to adhere to -fstrict-flex-arrays in both =1 and =2 where then =2 would only add the intermediate pointer results verification. I think that's reasonable if documented since the default behavior with -Wall will not change then unless the -fstrict-flex-arrays default is altered. > Oh my understanding of the consensus was to move flex array related diagnosis > from -Warray-bounds to -Wstring-flex-arrays as Qing has done. If only the > former exists then instead of removing the flex array related statement in the > documentation as Richard suggested, we need to enhance it to say that > behaviour of -Warray-bounds will depend on -fstrict-flex-arrays. > > -Warray-bounds does diagnosis beyond just flexible arrays, in case that's the > confusion. Richard. -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman; HRB 36809 (AG Nuernberg)