https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111398

            Bug ID: 111398
           Summary: GCC should warn if a struct with flexible array member
                    is declared static or onstack
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tg at mirbsd dot org
  Target Milestone: ---

If I have (-std=c99 and up) a…

struct foo {
        size_t len;
        char buf[];
};

… then I would like to be warned (at least with -Wextra or something) if I do
either of…

static struct foo a;  // this
struct foo b;         // this
extern struct foo x;  // and probably even this!
void bla(void) {
        static struct foo c;  // this
        struct foo d;         // and this
}

(Probably the same for GCC’s char buf[0]; extension.)

Reply via email to