> On Nov 22, 2022, at 3:16 AM, Richard Biener <rguent...@suse.de> wrote:
>
> On Mon, 21 Nov 2022, Qing Zhao wrote:
>
>>
>>
>>> On Nov 18, 2022, at 11:31 AM, Kees Cook <keesc...@chromium.org> wrote:
>>>
>>> On Fri, Nov 18, 2022 at 03:19:07PM +0000, Qing Zhao wrote:
>>>> Hi, Richard,
>>>>
>>>> Honestly, it?s very hard for me to decide what?s the best way to handle
>>>> the interaction
>>>> between -fstrict-flex-array=M and -Warray-bounds=N.
>>>>
>>>> Ideally, -fstrict-flex-array=M should completely control the behavior of
>>>> -Warray-bounds.
>>>> If possible, I prefer this solution.
>>>>
>>>> However, -Warray-bounds is included in -Wall, and has been used
>>>> extensively for a long time.
>>>> It?s not safe to change its default behavior.
>>>
>>> I prefer that -fstrict-flex-arrays controls -Warray-bounds. That
>>> it is in -Wall is _good_ for this reason. :) No one is going to add
>>> -fstrict-flex-arrays (at any level) without understanding what it does
>>> and wanting those effects on -Warray-bounds.
>>
>>
>> The major difficulties to let -fstrict-flex-arrays controlling
>> -Warray-bounds was discussed in the following threads:
>>
>> https://gcc.gnu.org/pipermail/gcc-patches/2022-October/604133.html
>>
>> Please take a look at the discussion and let me know your opinion.
>
> My opinion is now, after re-considering and with seeing your new
> patch, that -Warray-bounds=2 should be changed to only add
> "the intermediate results of pointer arithmetic that may yield out of
> bounds values" and that what it considers a flex array should now
> be controlled by -fstrict-flex-arrays only.
>
> That is, I think, the only thing that's not confusing to users even
> if that implies a change from previous behavior that we should
> document by clarifying the -Warray-bounds documentation as well as
> by adding an entry to the Caveats section of gcc-13/changes.html
>
> That also means that =2 will get _less_ warnings with GCC 13 when
> the user doesn't use -fstrict-flex-arrays as well.
Okay. So, this is for -Warray-bounds=2.
For -Warray-bounds=1 -fstrict-flex-array=N, if N > 1, should
-fstrict-flex-array=N control -Warray-bounds=1?
Qing
>
> 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)