public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Qing Zhao <qing.zhao@oracle.com>
To: Richard Biener <rguenther@suse.de>
Cc: Siddhesh Poyarekar <siddhesh@gotplt.org>,
	Kees Cook <keescook@chromium.org>,
	"joseph@codesourcery.com" <joseph@codesourcery.com>,
	"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
	"siddhesh@gcc.gnu.org" <siddhesh@gcc.gnu.org>
Subject: Re: [V2][PATCH 1/1] Add a new warning option -Wstrict-flex-arrays.
Date: Fri, 2 Dec 2022 14:43:25 +0000	[thread overview]
Message-ID: <40951541-3681-4FD0-B29E-F0D50511372B@oracle.com> (raw)
In-Reply-To: <nycvar.YFH.7.77.849.2212020719150.17722@jbgna.fhfr.qr>



> On Dec 2, 2022, at 2:20 AM, Richard Biener <rguenther@suse.de> 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.

Qing
>  We do all seem to agree on the first so it's easy
> to go forward with that?
> 
> Thanks,
> Richard.


  reply	other threads:[~2022-12-02 14:43 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-30 14:25 [V2][PATCH 0/1]Add " Qing Zhao
2022-11-30 14:25 ` [V2][PATCH 1/1] Add " Qing Zhao
2022-12-01 16:42   ` Kees Cook
2022-12-01 17:04     ` Qing Zhao
2022-12-01 17:18       ` Kees Cook
2022-12-01 17:48         ` Qing Zhao
2022-12-01 19:45     ` Siddhesh Poyarekar
2022-12-01 22:27       ` Qing Zhao
2022-12-01 23:19         ` Kees Cook
2022-12-01 23:53           ` Siddhesh Poyarekar
2022-12-02  7:16       ` Richard Biener
2022-12-02  7:20         ` Richard Biener
2022-12-02 14:43           ` Qing Zhao [this message]
2022-12-05 15:16             ` Richard Biener
2022-12-05 15:20               ` Qing Zhao
2022-12-02 14:40         ` Qing Zhao
2022-12-06 16:14 [V3][PATCH 0/2]Update -Warray-bounds with -fstrict-flex-arrays Qing Zhao
2022-12-06 16:14 ` [V2][PATCH 1/1] Add a new warning option -Wstrict-flex-arrays Qing Zhao
2022-12-06 16:16   ` Qing Zhao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=40951541-3681-4FD0-B29E-F0D50511372B@oracle.com \
    --to=qing.zhao@oracle.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=joseph@codesourcery.com \
    --cc=keescook@chromium.org \
    --cc=rguenther@suse.de \
    --cc=siddhesh@gcc.gnu.org \
    --cc=siddhesh@gotplt.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).