[C++-sig] Protected destructor compile error

Allen Bierbaum abierbaum at gmail.com
Wed Jun 21 23:53:36 CEST 2006

I have run into a compiler error with boost.python and I would like to
understand what is causing it so I can try to fix the problem.  This
is coming up in several places in the binding I am working on, so I am
hopeful if I can understand what is happening with one case I can fix
it everywhere.


I am wrapping a class, Camera, the method that is causing problems is:

bool Camera::calcViewRay (Line &line, Int32 x, Int32 y, const Viewport &port);

I am wrapping it (using pyplusplus) with this def:

    , &::osg::Camera::calcViewRay
    , ( bp::arg("line"), bp::arg("x"), bp::arg("y"), bp::arg("port") )
    , bp::default_call_policies() );

I get this error when building with boost 1.33.1 on fedora core 4 (gcc 4.0.2):

In static member function 'static void
boost::python::detail::value_destroyer<false>::execute(const volatile
T*) [with T = osg::Viewport]':
  instantiated from 'void
boost::python::detail::destroy_referent_impl(void*, T& (*)()) [with T
= const osg::Viewport]'
  instantiated from 'void
boost::python::detail::destroy_referent(void*, T (*)()) [with T =
const osg::Viewport&]'
  instantiated from
[with T = const osg::Viewport&]'
  instantiated from 'PyObject*
boost::python::detail::caller_arity<5u>::impl<F, Policies,
Sig>::operator()(PyObject*, PyObject*) [with F = bool
(osg::Camera::*)(osg::Line&, osg::Int32, osg::Int32, const
osg::Viewport&), Policies = boost::python::default_call_policies, Sig
= boost::mpl::vector6<bool, osg::Camera&, osg::Line&, int, int, const
  instantiated from 'PyObject*
PyObject*) [with Caller = boost::python::detail::caller<bool
(osg::Camera::*)(osg::Line&, osg::Int32, osg::Int32, const
osg::Viewport&), boost::python::default_call_policies,
boost::mpl::vector6<bool, osg::Camera&, osg::Line&, int, int, const
osg::Viewport&> >]'
src/osg_module2/Camera.pypp.cpp:459:   instantiated from here
error: 'virtual osg::Viewport::~Viewport()' is protected
error: within this context

It looks like there is a problem with the "const Viewport& port"
argument being passed.  For some reason the generated code seems to
want to be able to destroy instances of the Viewport class.  This
class has protected constructor and destructor as it is reference
counted and the user can only create them using a helper function

Can anyone describe what is happening here and what prerequisites
exist for this call to work?  Is there some call policy that I should
be using to make this work?


More information about the Cplusplus-sig mailing list