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