From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id EC60D3854575; Fri, 2 Dec 2022 07:20:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EC60D3854575 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 E674D21B88; Fri, 2 Dec 2022 07:20:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1669965626; 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=8vZccqsEwtQP6Zq6BtOQst4zTVLsb90pU5Y+z9KiJXU=; b=xj2Gs7/ZHZRSI0EN+s3esfJ3LupuAiklR1yMCHtNsynv+L3mxnw6obDV/u1hA7eoRvFtkj u5zLDIOXmfPkXFkZD9kQ+Nv4Aw6lKC+5vHXlKNcO/lPBnQa0/8mQ6fezzTsKIYma+/xM9S xXntj5qXZL7dyuuTYaVI3e7RSgKjl8s= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1669965626; 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=8vZccqsEwtQP6Zq6BtOQst4zTVLsb90pU5Y+z9KiJXU=; b=BXbXJCaOgw5t4xLRoLQwiLhKY/JIvf1jCs/rYqrmO0raNa7iyE7KpG1NVNJl6N60fhpwWe YaGaa/a0VXrhbrDA== 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 B5D782C141; Fri, 2 Dec 2022 07:20:26 +0000 (UTC) Date: Fri, 2 Dec 2022 07:20:26 +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: 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 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. We do all seem to agree on the first so it's easy to go forward with that? Thanks, Richard.