title: A friend function accessing a private member of a friend class
body: <p>Following <a href="https://www.youtube.com/watch?v=yH1-uy9FYKE" rel="nofollow noreferrer">the Czech song from <em>Eurovision 2019 in Tel-Aviv</em></a></p>
  <p>It is known that in C++ a friend of a friend is <em>not (automatically)</em> a friend.</p>
  <p>Clang however differs on the following code with GCC and MSVC:</p>
  <pre><code>class A {
  public:    
      // forward declaration
      class Inner2;
  
  private:
      class Inner1 {
          char foo;
          friend class Inner2;
      };
  public:
      class Inner2 {
          Inner1 i;
      public:
          bool operator==(Inner2 other) {
              return i.foo == other.i.foo; // OK by GCC, Clang and MSVC++
          }
          friend bool operator!=(Inner2 a, Inner2 b) {
              return a.i.foo != b.i.foo; // Clang accepts, GCC and MSVC++ reject
          }
      };
  };
  </code></pre>
  <p>Code: <a href="https://godbolt.org/z/rn48PTe1Y" rel="nofollow noreferrer">https://godbolt.org/z/rn48PTe1Y</a></p>
  <p>Which one is correct?
  If Clang is wrong by being too permissive, what is the best way to allow access (other than providing a public getter?)</p>
  <hr />
  <p><sub>A note: if the friend function is just declared in the class and implemented outside, <a href="https://godbolt.org/z/9Y19hWGPE" rel="nofollow noreferrer">both Clang and GCC reject the code</a>.</sub></p>