From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 798D73888833; Mon, 5 Dec 2022 15:16:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 798D73888833 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-out2.suse.de (Postfix) with ESMTP id 9C0501F747; Mon, 5 Dec 2022 15:16:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1670253376; 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=Sq6NqSPoKq0TwtYT9JiRy3K2LkzgOvIeZZ3Q5+Uh9mE=; b=0UA3mI8w1HSKFfET5w5mdrPyQJjjzZ03jCbD6dIJfcwA6VOI9MVD0DkssG6ckeaZgggPnn G0T4azRsh+/zdDuy+wDcyTtX6uncRwYHLILJroXoYLvode7A3YTA3xknYGfJiejGEiQahj s89iYxbp9FDy3Je9HR8WI2bfmlCIlgw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1670253376; 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=Sq6NqSPoKq0TwtYT9JiRy3K2LkzgOvIeZZ3Q5+Uh9mE=; b=V4pvzTOqzpMIQH3dxDNug5Pq5vYLgfUJi1DkPhmN74cvmNqyppbYh5oEz8F65eyIFrEcXJ DYfxGhJO/R3SsHCg== 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 567B42C141; Mon, 5 Dec 2022 15:16:15 +0000 (UTC) Date: Mon, 5 Dec 2022 15:16:15 +0000 (UTC) From: Richard Biener To: Qing Zhao cc: Siddhesh Poyarekar , Kees Cook , "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: <40951541-3681-4FD0-B29E-F0D50511372B@oracle.com> 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> <40951541-3681-4FD0-B29E-F0D50511372B@oracle.com> 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 Fri, 2 Dec 2022, Qing Zhao wrote: > > > > On Dec 2, 2022, at 2:20 AM, Richard Biener wrote: > > > > On Fri, 2 Dec 2022, Richard Biener wrote: > > > >> 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. > > > > Btw, your patch seems to implement the above plus adds > > -Wstrict-flex-arrays. It seems it could be split into two, doing > > the -Warray-bounds adjustment as first and the -Wstrict-flex-arrays > > addition as second. > > Yes, implementation should be very easy to be adjusted to drop the new -Wstrict-flex-arrays option. > But I still feel the new -Wstrict-flex-arrays option is good to add. Can you split the patch and re-post? I'll quickly approve the first part and will think harder on the second. Thanks, Richard. > Qing > > We do all seem to agree on the first so it's easy > > to go forward with that? > > > > Thanks, > > 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)