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

            Bug ID: 121944
           Summary: -Wold-style-declaration: False negative with 'auto
                    static' (C23)
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: [email protected]
  Target Milestone: ---

alx@debian:~/tmp/auto$ cat autostatic.c 
int
main(void)
{
        int static  is;
        auto static as2 = 0;
}
alx@debian:~/tmp/auto$ gcc -std=c23 -Wall -Wextra autostatic.c  -Wno-unused
autostatic.c: In function ‘main’:
autostatic.c:4:9: warning: ‘static’ is not at beginning of declaration
[-Wold-style-declaration]
    4 |         int static  is;
      |         ^~~


This auto acts as a type specifier, similar to int.  'static' should thus go
first, and this declaration has them reversed.  I'd expect this diagnostic to
trigger.

While the C23 standard says it's still a storage-class specifier, that's weird,
and shouldn't stop us from diagnosing this.

Reply via email to