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

            Bug ID: 108690
           Summary: -Wstrict-prototypes too picky for C23
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: eggert at gnu dot org
  Target Milestone: ---

We ran into this problem in Gnulib when considering how to migrate towards C23.

With GCC 12.2.1 20221121 (Red Hat 12.2.1-4) on x86-64, compile the following
one-line program t.c with 'gcc -S -std=gnu2x -Wstrict-prototypes t.c':

int f ();

GCC complains:

t.c:1:1: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
    1 | int f ();
      | ^~~

This diagnostic is incorrect, because in C23 every function declaration and
definition is prototyped: 'int f ();' means the same thing as 'int f (void);'.
This incorrect warning is causing us to think we should stop using
-Wstrict-prototypes, but that would have a negative consequence in the common
case of pre-C23 builds.

In short, -Wstrict-prototypes should be a no-op in C23, since all functions are
prototyped in C23.

Reply via email to