http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32204

David Piepgrass <dpiepgrass at mentoreng dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dpiepgrass at mentoreng dot
                   |                            |com

--- Comment #3 from David Piepgrass <dpiepgrass at mentoreng dot com> 
2012-03-26 21:20:11 UTC ---
I have run into this bug or a similar bug while porting my code from MSVC to
GCC. I need to declare that a class in the global namespace is a friend of my
template class. However, I discovered that the bug still occurs if no templates
are involved. Here's my repro:

class Friend;
namespace Foo
{
    class Base {
    };
    class Derived : protected Base {
        friend class Friend;
    };
}
class Friend {
    void F(const Foo::Derived* data) const 
    {
        // error: 'Foo::Base' is an inaccessible base of 'Foo::Derived'
        const Foo::Base* dataB = data;
    }
};

The problem disappears if either (A) Derived is not in a namespace, or (B)
Friend is in a namespace (the forward declaration of Friend is required and, of
course, must be put in the namespace too).

Reply via email to