https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86601
Bug ID: 86601 Summary: g++ accepts 'friend' at ill-formed positions in the decl-specifier-seq Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: zhonghao at pku dot org.cn Target Milestone: --- g++ accepts this: struct S { class T friend; unsigned friend char; }; Both of these are illegal by [class.friend]p3, which requires the 'friend' decl-specifier to be the first in the decl-specifier-seq for non-function declarations. BTW, clang++ rejects it: code0.cpp:2:10: error: 'friend' must appear first in a non-function declaration class T friend; ^ code0.cpp:3:11: error: 'friend' must appear first in a non-function declaration unsigned friend char; ^ 2 errors generated.