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

So, you suggested to drop the new option -Wstrict-flex-arrays?
How about the new warnings on the misuse of flex arrays? Shall we drop them too?
Or we issue such new warnings with  -Warray-bounds + -fstrict-flex-arrays=N?

I still think that the new -Wstrict-flex-arrays to only issue the misuse of 
flex arrays is necessary to add.
Otherwise, such warning messages will be buried among a lot of out-of-bounds 
warnings.
> 
> 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.
Yes, the default behavior for -Wall, or  -Warray-bounds are not changed.

Qing
> 
>> 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.
> 
> Richard.
> 
> -- 
> Richard Biener <rguent...@suse.de>
> SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg,
> Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman;
> HRB 36809 (AG Nuernberg)

Reply via email to