https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101836
--- Comment #27 from Qing Zhao <qing.zhao at oracle dot com> --- > On Jun 14, 2022, at 11:39 AM, siddhesh at gcc dot gnu.org > <gcc-bugzi...@gcc.gnu.org> wrote: > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101836 > > --- Comment #26 from Siddhesh Poyarekar <siddhesh at gcc dot gnu.org> --- > (In reply to qinzhao from comment #25) >> So, based on all the discussion so far, how about the following: >> >> ** add the following gcc option: >> >> -fstrict-flex-arrays=[0|1|2|3] >> >> when -fstrict-flex-arrays=0: >> treat all trailing arrays as flexible arrays. the default behavior; > > Wouldn't this be -fno-strict-flex-arrays, i.e. the current behaviour? Yes, it’s the same. =0 is aliased with -fno-strict-flex-arrays. The point is, the larger the value of LEVEL, the stricter with treating the flexing array. i.e, 0 is the least strict, and 3 is the strictest mode. But we can delete the level 0 if not necessary. > >> when -fstrict-flex-arrays=1: >> Only treating [], [0], and [1] as flexible array; >> >> when -fstrict-flex-arrays=2: >> Only treating [] and [0] as flexible array; >> >> when -fstrict-flex-arrays=3: >> Only treating [] as flexible array; The strictest level. > > If yes, then you end up having: > > -fstrict-flex-arrays=[1|2|3] > > with, I suppose, 1 as the default based on Jakub's comment about maximum > compatibility support. Yes. And 3 is the one Kees requested for kernel usage.