This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 120a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2026-06-27
(From submission #906.)
There is no rule that disallows friend declarations outside classes.
Furthermore, there is no normative text that specifies which class grants friendship. Also, there is no specification for the effects of the friend specifier on a function declaration.
Proposed resolution (approved by CWG 2026-06-26):
Insert before and change in 9.2.5 [dcl.friend] paragraph 1 as follows:
A declaration whose decl-specifier-seq contains the decl-specifier friend or that is a friend-type-declaration is a friend declaration. Such a declaration shall inhabit a class scope. If it is not a friend-type-declaration (11.4.1 [class.mem.general]), it shall declare a function. [Note 1: A friend declaration can be the declaration of a template-declaration (13.1 [temp.pre], 13.7.5 [temp.friend]). —end note]
No storage-class-specifier shall appear in the decl-specifier-seq of a friend declaration.
TheA friendspecifierdeclaration is used to specify access to class members; see 11.8.4 [class.friend].
Change in 11.8.4 [class.friend] paragraph 1 as follows:
A friend of a class is a function or class that is given permission to name the private and protected members of the class.A class specifies its friends, if any, by way of friend declarations.A friend declaration F (9.2.5 [dcl.friend]) inhabiting the class scope of a class or class template C specifies that C grants friendship to the entity declared by F. Such declarations give special access rights to the friends, but they do not make the nominated friends members of the befriending class.
Change in 11.8.4 [class.friend] paragraph 3 as follows:
A friend declaration that does not declare a function shall be a friend-type-declaration. [Note 1: A friend declaration can be the declaration in a template-declaration (13.1 [temp.pre], 13.7.5 [temp.friend]). —end note]
Remove 11.8.4 [class.friend] paragraph 7 as follows:
No storage-class-specifier shall appear in the decl-specifier-seq of a friend declaration.