From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by sourceware.org (Postfix) with ESMTPS id 593143858D32 for ; Thu, 1 Dec 2022 16:42:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 593143858D32 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-pj1-x1036.google.com with SMTP id b11so2377305pjp.2 for ; Thu, 01 Dec 2022 08:42:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=61IHx8sglZe8Gl/I30HMxWp7hfmg7tQVeRzMJnLoBDc=; b=i+dqxEIeNiYg6t06m5tbchR8Er7ixq/lB4WYvR2jgA59n6fsPfarfNbxLPIXoI0iCW 06NY0acZLGrfkM0Og2a5Gnaa5/jXAOzmc0DjvlrEflpFEKj1tp50Tv9jfDhEArAZO0Mf MYykkUK/xJZe/YfTorVHTP32xNTQ2RG0N2Q8E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to: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=61IHx8sglZe8Gl/I30HMxWp7hfmg7tQVeRzMJnLoBDc=; b=vSeviDved9B8uGozVsQBwBPdiSaU2ZGssIXvCqRA6by165+C5bsTuvt3qKykz07Tuv nLst2kwL7dmUSPiEPnEgs+0BQDohl196O16WV3Tfior2ucdtpr3zEQQFUfAeZIoyydBW geK00YBU5Sk6eLX4vJn7GR4ll4crfC1B2eqdSxJvop91OiobrqXi0QD2PABrQ2D15ud8 IczsEfwc/RMUP+IrYNNzP7tXo3EwCA/145pi0BrrC4mUDU7MfjwLOFxddKQNR50dC6UQ 9kF7BCifEAaG1TSSNM9ej30rEvaBQ37pFB3wm6Yihlu82HmJUrCp4f0ZOS3V0EmnAru2 6luA== X-Gm-Message-State: ANoB5pkU1tP51kuocmuvRAoym86PQKdCYkjniAAD+d1DrS5c2iu8Moo1 jxyT/+NpSa6vGIvqOlR0vVXTiw== X-Google-Smtp-Source: AA0mqf78oDekQubDqw1eirdEzrHRTIk02LIOmVJy/DqTDsRPYz26tWM0fGCEx3EiUvkcd1U7jUY1gg== X-Received: by 2002:a17:90a:c68d:b0:219:80b:6ea with SMTP id n13-20020a17090ac68d00b00219080b06eamr35812790pjt.212.1669912959323; Thu, 01 Dec 2022 08:42:39 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id i17-20020a170902c95100b00189847cd4acsm3919848pla.237.2022.12.01.08.42.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 08:42:38 -0800 (PST) Date: Thu, 1 Dec 2022 08:42:38 -0800 From: Kees Cook To: Qing Zhao Cc: rguenther@suse.de, 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. Message-ID: <202212010840.C963E72661@keescook> References: <20221130142556.3079865-1-qing.zhao@oracle.com> <20221130142556.3079865-2-qing.zhao@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221130142556.3079865-2-qing.zhao@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 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? Are you trying to split code gen (-fstrict-flex-arrays) from warnings? Is that needed? -- Kees Cook