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

            Bug ID: 82922
           Summary: Request: add -Wstrict-prototypes to -Wextra as K&R
                    style is obsolescent
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: antox at ml dot lv
  Target Milestone: ---

K&R style function declarations and definitions are marked obsolescent (C89
3.9.4,5, C99 6.11.6,7, C11 6.11.6,7). Maybe it is reasonable to include
-Wstrict-prototypes in -Wextra (before it becomes appropriate in -Wall)?

K&R style still can be encountered in the wild and, to someone uninitiated, may
appear like a less cluttered alternative. gcc-5.3.0 -Wall -Wextra compiles the
following code without warning about missing prototype and unchecked arguments:

double f(t, x, y)
        double t, x, y;
{ }
int main(void) {
        //f(0.0, 1.0, 1.0);
        f(0, 1, 1);  // UB
}

Unprototyped functions can be diagnosed by combining
-Wimplicit-function-declaration and -Wstrict-prototypes. The former is in -Wall
and imposed since C99.

-Wold-style-definition cases are covered by -Wstrict-prototypes too.

-Wold-style-declaration (obsolescent: C89 3.9.3, C99 6.11.5, C11 6.11.5) is
included in -Wextra.

There has been a bit of discussion on gcc-help:
https://gcc.gnu.org/ml/gcc-help/2017-11/msg00001.html

Reply via email to