https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99032
Bug ID: 99032 Summary: GCC accepts attributes on friend declarations (not definitions) Product: gcc Version: 10.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: dangelog at gmail dot com Target Milestone: --- Hi, The following code is accepted by GCC 10.2: struct S { [[deprecated]] friend void f(); }; No errors and no warnings are generated under -Wall -Wextra -pedantic. The code is however ill-formed: an attribute cannot appear on a friend declaration which isn't also a definition: https://eel.is/c++draft/dcl.attr#grammar-5.sentence-3 If an attribute-specifier-seq appertains to a friend declaration ([class.friend]), that declaration shall be a definition. For comparison, Clang rejects this, and MSVC accepts it (without warnings).