> On Mar 27, 2023, at 11:43 AM, Jakub Jelinek <ja...@redhat.com> wrote: > > On Mon, Mar 27, 2023 at 01:38:34PM +0000, Qing Zhao wrote: >> >> >>> On Mar 23, 2023, at 4:14 PM, Joseph Myers <jos...@codesourcery.com> wrote: >>> >>> On Thu, 23 Mar 2023, Qing Zhao via Gcc-patches wrote: >>> >>>> +Wgnu-variable-sized-type-not-at-end >>>> +C C++ Var(warn_variable_sized_type_not_at_end) Warning >>>> +Warn about structures or unions with C99 flexible array members are not >>>> +at the end of a structure. >>> >>> I think there's at least one word missing here, e.g. "that" before "are". >> >> Will fix it. >>> >>>> +Please use warning option @option{-Wgnu-variable-sized-type-not-at-end} >>>> to >>>> +identify all such cases in the source code and modify them. This >>>> extension >>>> +will be deprecated from gcc in the next release. >>> >>> We don't generally say "in the next release" in the manual (or "deprecated >>> from gcc"). Maybe it *is* deprecated, maybe it will be *removed*, or will >>> *start to warn by default*, in some specified version number (giving a >>> version number seems better than "next release"), but "will be deprecated" >>> is odd. >> How about the following: >> >> +Please use warning option @option{-Wgnu-variable-sized-type-not-at-end} to > This is certainly misnamed.
The name “-Wgnu-variable-sized-type-not-at-end” was just used the warning name from CLANG. -:) Shall we use the same name as CLANG? Or we invent a new name? > GNU variable sized type not at the end of a > struct is something like > void bar (void *); > void foo (int n) { > struct S { int a; int b[n]; int c; } s; > s.a = 1; > __builtin_memset (s.b, 0, sizeof (s.b)); > s.c = 3; > bar (&s); > } > Certainly not flexible array members in the middle of structure. Right now, with -Wpedantic, we have the following warning for the above small case: t2.c:3:24: warning: a member of a structure or union cannot have a variably modified type [-Wpedantic] 3 | struct S { int a; int b[n]; int c; } s; | ^ Do we have a definition for “GNU variable sized type” now? Shall we include "flexible array members” and" the structure/union with a flexible array members at the end" into “GNU variable sized type”? thanks. Qing > >> +identify all such cases in the source code and modify them. This warning >> will be >> + on by default starting from GCC14. > > Jakub