https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118271

            Bug ID: 118271
           Summary: GCC complains on valid friend declaration of
                    overloaded type conversion operator in a derived class
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: wangbopku15 at gmail dot com
  Target Milestone: ---

The following test is accepted by clang, MSVC, and EDG, but rejected by gcc:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

class A{};
class B {
public:
  operator A *() const;
};

class C : A {
    friend B::operator A *() const;
};

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The diagnostic is somewhat confusing, which seems to complain that the
constructor of 'A' is not accessible:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

<source>:8:24: error: 'class A A::A' is inaccessible within this context
    8 |     friend B::operator A *() const;
      |                        ^
<source>:1:8: note: declared here
    1 | class A{};
      |        ^

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Please see https://godbolt.org/z/8v51E93Pd

Reply via email to