mercredi 2 décembre 2015

friend class must be public, clang's bug?

I tried to compile someone's intrusive_ptr with clang 3.7 & -std=c++1z, and it generates errors below ( GCC 5.2.1 is Ok ) :

In file included from test_intrusive_ptr.cpp:10: ./intrusive_ptr.hpp:539:53: error: '_Weak_observer' is a private member of 'std::_Intrusive_ptr_impl::_Deleteable<std::default_delete<foo> >' using _Observer = typename intrusive_base<_T, _D>::_Weak_observer; ^ test_intrusive_ptr.cpp:27:21: note: in instantiation of template class 'std::intrusive_weak_ptr<foo>' requested here template class std::intrusive_weak_ptr<foo>; ^ ./intrusive_ptr.hpp:141:9: note: implicitly declared private here class _Weak_observer : public _Ref_count_base { ^ ./intrusive_ptr.hpp:556:24: error: '__create_observer' is a private member of 'std::_Intrusive_ptr_impl::_Deleteable<std::default_delete<foo> >' __observer = __rhs->__create_observer(); ^ test_intrusive_ptr.cpp:27:21: note: in instantiation of member function 'std::intrusive_weak_ptr<foo, std::default_delete<foo> >::intrusive_weak_ptr' requested here template class std::intrusive_weak_ptr<foo>; ^ ./intrusive_ptr.hpp:174:20: note: implicitly declared private here _Weak_observer * __create_observer() const volatile { ^ 2 errors generated.

But the code compiles well after I add public at line 134. Is that a bug in Clang?

Aucun commentaire:

Enregistrer un commentaire