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

2025-09-18


3068. Access checking in friends involving qualified-ids

Section: 11.8.1  [class.access.general]     Status: open     Submitter: Corentin Jabot     Date: 2025-05-24

(From submission #709.)

Consider:

  class D {
    class E {
      class F {};
      friend void foo1(D::E::F& q);
    };
    friend void foo1(D::E::F& q);
  };
  void foo1(D::E::F& q) {}

The specification in 11.8.1 [class.access.general] paragraph 6 leads to the question whether we are "naming F from the declaration" of ::D or of ::foo1. There is implementation divergence.

Another example:

  class G {
    using T = int;
    friend void foo(T);
  };

  class H {
    friend void foo(G::T);
  }

It might be desirable to carve out a special rule for friend declarations, allowing both examples, because earlier friend declarations have already granted access.