https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92438
Bug ID: 92438 Summary: Function declaration parsed incorrectly with `-std=c++1z` Product: gcc Version: 9.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: sagebar at web dot de Target Milestone: --- Created attachment 47204 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47204&action=edit Demonstration of incorrect parsing + several work-arounds Functions declarations returning a typedef'ed struct-type, and having their names wrapped by parenthesis, as well as a calling-convention attribute within those parenthesis, causes g++ to think that it's a variable declaration, rather than a function declaration. Essentially, given something like this: ``` typedef struct myint_struct { int x; } MYINT; ``` All of the following declarations get parsed correctly: ``` MYINT (myabs1)(MYINT x); MYINT __attribute__((stdcall)) myabs2(MYINT x); struct myint_struct (__attribute__((stdcall)) myabs3)(MYINT x); ``` However, this declaration (incorrectly) causes a parser error: ``` MYINT (__attribute__((stdcall)) myabs4)(MYINT x); ``` Note that the problem only appears when `-std=c++1z` or `-std=gnu++1z` is passed on the commandline, such that you can re-produce the problem with the attached file and: ``` g++ -c -std=c++1z attached-file.cc g++ -c -std=gnu++1z attached-file.cc ``` However, compiling it without any special std=... flag doesn't produce any errors: ``` g++ -c attached-file.cc ```