From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by sourceware.org (Postfix) with ESMTPS id 2B8D73858C50 for ; Thu, 1 Dec 2022 23:19:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2B8D73858C50 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pf1-x434.google.com with SMTP id w2so1788074pfq.12 for ; Thu, 01 Dec 2022 15:19:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=cl3Pw4NVwkPYTtgGgeLhCAEgFznT9aMq3sogOzSOOi8=; b=oBA3SwDsXcdxxQm9ELf5KVO9RtN7s90Kl0A3p+B8p2k0HyICJz/mb/pAM0SxH84o8S X0Jgsaj/LVlBW+yZYIb7ts5XcTMwJgMBj5Kb03kw+R+EFS3PGtA6Egh1tcpZBK/JORUm 8WEw8zhfamajJAgThefX/zC8Z0znzEET+OGlY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cl3Pw4NVwkPYTtgGgeLhCAEgFznT9aMq3sogOzSOOi8=; b=oTjOaYM+qL0T9zrdLBUiVew8bwdlLJ7Ckg4OVD2GydfW1sMg7lwrZUnDLLWO9o3F/e Zg2WaQSSCOQElbMgSc5HA0BQ78pLpzN9ZawKVX3x4XY1s795oIw1SrDaI+UWgWjSatVo so2Maqa+tBnxXRCzhauvOcxlP4JvqeAd4RJDWjEnihYnpw6LU+AC6BdGC9ictplbQvnM KzivHzga50FUgjT7cS5RRDBIHjQIfacyybq9rKzEQy8xjOMohU3xDOYtcRDGNJYBhpjc pF1Ebj0fpAfuwZmYKEOYBi9sIjiRzFvhRFwWCnmlwgpV7e1Sm4ttjIm9CzrMbarf6emY /4kA== X-Gm-Message-State: ANoB5plA+nOv6tG2a/XDVAKhWe/9iucsjFH+/WxKFwMk+8j6FXphq1Mx ZrgpquyfaeqIgwUwZtOIt1Ge3A== X-Google-Smtp-Source: AA0mqf56DSuCJtx0eN1wKoRmXfv6XqKAD+3SUBv07OxZwUfYeQFpDGe0MF4SRXVDik6URPZMX1ojww== X-Received: by 2002:a62:b402:0:b0:56e:8f96:6b2e with SMTP id h2-20020a62b402000000b0056e8f966b2emr70503679pfn.18.1669936744074; Thu, 01 Dec 2022 15:19:04 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id s1-20020a625e01000000b0056b4c5dde61sm3859189pfb.98.2022.12.01.15.19.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 15:19:03 -0800 (PST) Date: Thu, 1 Dec 2022 15:19:02 -0800 From: Kees Cook To: Qing Zhao Cc: Siddhesh Poyarekar , Richard Biener , "joseph@codesourcery.com" , gcc Patches Subject: Re: [V2][PATCH 1/1] Add a new warning option -Wstrict-flex-arrays. Message-ID: <202212011518.5C7B46D21@keescook> 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> <7F963B56-040D-4384-B51B-3A63A3E38249@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <7F963B56-040D-4384-B51B-3A63A3E38249@oracle.com> X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,JMQ_SPF_NEUTRAL,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no 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, Dec 01, 2022 at 10:27:41PM +0000, Qing Zhao wrote: > Hi, Sid, > > Thanks a lot for the input. > > After more thinking based on your and Kees’ comments, I have the following thought: > > 1. -fstrict-flex-arrays=level should control both GCC code gen and warnings consistently; > 2. We need warnings specifically for -fstrict-flex-arrays=level to report any misuse of flexible > array corresponding to the “level” to gradually encourage language standard. > > So, based on the above two, I think what I did in this current patch is correct: > > 1. We eliminate the control from -Warray-bounds=level on treating flex arrays, > now only "-fstrict-flex-arrasy=level" controls how the warning treating the flex arrays. > 2. We add a separate new warning -Wstrict-flex-arrays to report any misuse corresponding to > the different level of -fstrict-flex-arrays. > > Although we can certainly merge these new warnings into -Warray-bounds, however, as Sid mentioned, > -Warray-bounds does issue a lot more warnings than just flexible arrays misuse. I think it’s necessary > To provide a seperate warning to only issue flexible array misuse. > > Let me know if you have any more comments on this. Okay, that seems good. Given that -Warray-bounds is part of -Wall, what should happen for -Wstrict-flex-arrays=N? -- Kees Cook