This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 119e. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2026-05-20


3193. Missing restrictions and effects for friend declarations

Section: 9.2.5  [dcl.friend]     Status: open     Submitter: Tim Song     Date: 2026-05-14

(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.

Possible resolution:

  1. 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 is a friend declaration. Such a declaration shall inhabit a class scope. It shall either be a friend-type-declaration (11.4.1 [class.mem.general]) or declare a function. [Note 1: A friend declaration can be the declaration in 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.

    The A friend specifier declaration is used to specify access to class members; see 11.8.4 [class.friend].

  2. 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 C specifies that C grants friendship to the class or function 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.
  3. 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]
  4. 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.