[Bug c++/69500] New: friend of enclosed class not allowed access to private move method

hadrielk at yahoo dot com gcc-bugzilla@gcc.gnu.org
Tue Jan 26 20:11:00 GMT 2016


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

            Bug ID: 69500
           Summary: friend of enclosed class not allowed access to private
                    move method
           Product: gcc
           Version: 5.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hadrielk at yahoo dot com
  Target Milestone: ---

This might be related and/or a duplicate of bug 60799, but I can't be sure.

The following does not compile in 5.3.0 (nor as far back as 4.7.3, though I
didn't try before that):

/////////////////////////////////////////////
class Outer
{
public:
    class Inner
    {
    public:
        Inner() = default;
        ~Inner() {}  // user-defined, not default
    private:
        Inner(Inner&&) = default;
        friend class Outer; // this isn't being honored
    };
    Inner inners[1] = {};
};

int main()
{
    Outer v;
}
/////////////////////////////////////////////


Result:
main.cpp: In function 'int main()':
main.cpp:18:11:   in constexpr expansion of 'v.Outer::Outer()'
main.cpp:10:9: error: 'constexpr Outer::Inner::Inner(Outer::Inner&&)' is
private
         Inner(Inner&&) = default;
         ^
main.cpp:18:11: error: within this context
     Outer v;
           ^

The odd thing is if you either define the move constructor, or default the
destructor, or do both, then it compiles fine.


More information about the Gcc-bugs mailing list