From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from olivedrab.birch.relay.mailchannels.net (olivedrab.birch.relay.mailchannels.net [23.83.209.135]) by sourceware.org (Postfix) with ESMTPS id 7C9B93858D35; Thu, 1 Dec 2022 19:45:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7C9B93858D35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gotplt.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 41D2E41D3D; Thu, 1 Dec 2022 19:45:52 +0000 (UTC) Received: from pdx1-sub0-mail-a305.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 8834F41B1A; Thu, 1 Dec 2022 19:45:51 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1669923951; a=rsa-sha256; cv=none; b=baRD2+IxUYmreBIDay7uz47eLMbvHYER5teLRdiRImMVTCfWeg7qFZ6q8e+JX3rp8riIlz yuvm0sqg+wpRpN7qNE6/v1NoYJTKsN9NgMFGh5MvtVzAKMuYzaIDYhVuUGxelUigbz1L9I Z9CawxmrBoD3md8gt6W4+U+5bEw6HCQMralZ62j16dVOWlOkqSNnCXa4HVHlLnG3WCV7q+ rdAYbHLMpiYN6OvjrriOvNIds1WaWFCIP7jjcvOJhgAIWWkJQlqoqthux/kATqmlhMBr7n cC+zVNbuRy77sF3FXuzoSqRQvWIS2aMGvsXtCgrqh3RQayezO23cir3tPtGHiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1669923951; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=IUyZG5nE5gsk6/+BhcphvpYizqJL+2Bg3XZVcgXq2Tc=; b=AFPGe1LQPTHDXC7NG4gHGz/qUq5lee4x/rH+hwwmueFDGEU+NGU7ATECFX3o7aVKClej3B JHUKTkhPrJqrr9XOZkhcEvTjwkq74lMSwy0doC2SZYl5r5hiVobNr6+Rvj8TZPnrnz7V6/ Wr1mCvr0k3UV1eoKgBKyk/7qbFFk3jECVm1Fs+Im4iUpnTqWkraN7tOX12T6YyhOAt7qxn IGMvFCtUuhHn+daMrBaqrPK/mz5Jeh1GSg/JgJdI5V+PBD+fpqXxOhy1ZLYSQRvvT0pl+p 7eedrj01s/a3c9DOl1TuJ2bpUYA+PkLU3v7Z0chC9ber+WJ3tCEimCbA8S7CkA== ARC-Authentication-Results: i=1; rspamd-84789cff4b-q5zjm; auth=pass smtp.auth=dreamhost smtp.mailfrom=siddhesh@gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Shoe-Chief: 605a351b3358c663_1669923952044_955449736 X-MC-Loop-Signature: 1669923952044:1715418266 X-MC-Ingress-Time: 1669923952044 Received: from pdx1-sub0-mail-a305.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.97.48.119 (trex/6.7.1); Thu, 01 Dec 2022 19:45:51 +0000 Received: from [192.168.0.182] (bras-base-toroon4834w-grc-23-76-68-24-147.dsl.bell.ca [76.68.24.147]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a305.dreamhost.com (Postfix) with ESMTPSA id 4NNRQ46SzWzbp; Thu, 1 Dec 2022 11:45:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gotplt.org; s=dreamhost; t=1669923950; bh=IUyZG5nE5gsk6/+BhcphvpYizqJL+2Bg3XZVcgXq2Tc=; h=Date:Subject:To:Cc:From:Content-Type:Content-Transfer-Encoding; b=HPPJHVo8zv73ovJeWLHMU0Ikem0KTDLytaznPRbHO6GAL061wYwyrKIPRnF3OiwnG BDdO7t663VCSFiyo4fUbOw2WK5pi0V4VjHnHYFF1iuloDRkS+ZhMNGoQ83q95TsXbI i0iX7+2st1CpzP0G4A5GfBtlEpQS13L8vcwSAsOZ+CP8pr1Tps8kmCfa3mZLIOfOgq qWrBouRpnuy8dhv2XNzzrzf5aFBD70bL9V/0ORolVq7W4+6yPuY5lnoQGTKQ7GCjXP YRH9ct2tZkcpJxE+bKGiCNIfajmvZqfL/wTn8MHgtRkqDbloU1PQkTj1y18baW1DK2 1FtQUFFYxHdnQ== Message-ID: <898dfeed-f392-fb86-7fbd-f99d335c7a64@gotplt.org> Date: Thu, 1 Dec 2022 14:45:47 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: Re: [V2][PATCH 1/1] Add a new warning option -Wstrict-flex-arrays. Content-Language: en-US To: Kees Cook , Qing Zhao Cc: rguenther@suse.de, joseph@codesourcery.com, gcc-patches@gcc.gnu.org, siddhesh@gcc.gnu.org References: <20221130142556.3079865-1-qing.zhao@oracle.com> <20221130142556.3079865-2-qing.zhao@oracle.com> <202212010840.C963E72661@keescook> From: Siddhesh Poyarekar In-Reply-To: <202212010840.C963E72661@keescook> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3031.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,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 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? 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. Sid