Opened 14 years ago
Last modified 13 years ago
#2776 new Bugs
[fix in git] Failed to wrap classes with virtual inheritance
Reported by: | Owned by: | Dave Abrahams | |
---|---|---|---|
Milestone: | Boost 1.39.0 | Component: | python USE GITHUB |
Version: | Severity: | Problem | |
Keywords: | Cc: |
Description
Hi!
I've just generated a wrapper for the simple classes with virtual function and virtual inheritance with Py++ and generated code is failed to compile. Without virtual inheritance everything is ok.
Error log is below, source and generated files are in attachment.
% c++ -I/usr/include/python2.5 -lboost_python -shared -o test.so test.cxx /usr/include/boost/python/class.hpp: In static member function `static void boost::python::detail::error::virtual_function_default<T, Fn>::must_be_derived_class_member(const Default&) [with Default = void (Petq_wrapper::*)(), T = Petq_wrapper, Fn = void (Vasq::*)()]': /usr/include/boost/python/class.hpp:565: instantiated from `void boost::python::class_<T, X1, X2, X3>::def_default(const char*, Fn, const Helper&, mpl_::bool_<true>) [with Fn = void (Vasq::*)(), Helper = boost::python::detail::def_helper<void (Petq_wrapper::*)(), boost::python::detail::not_specified, boost::python::detail::not_specified, boost::python::detail::not_specified>, W = Petq_wrapper, X1 = boost::python::bases<Vasq, mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_>, X2 = boost::noncopyable_::noncopyable, X3 = boost::python::detail::not_specified]' /usr/include/boost/python/class.hpp:548: instantiated from `void boost::python::class_<T, X1, X2, X3>::def_impl(T*, const char*, Fn, const Helper&, ...) [with T = Petq, Fn = void (Vasq::*)(), Helper = boost::python::detail::def_helper<void (Petq_wrapper::*)(), boost::python::detail::not_specified, boost::python::detail::not_specified, boost::python::detail::not_specified>, W = Petq_wrapper, X1 = boost::python::bases<Vasq, mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_>, X2 = boost::noncopyable_::noncopyable, X3 = boost::python::detail::not_specified]' /usr/include/boost/python/class.hpp:608: instantiated from `void boost::python::class_<T, X1, X2, X3>::def_maybe_overloads(const char*, Fn, const A1&, ...) [with Fn = void (Vasq::*)(), A1 = void (Petq_wrapper::*)(), W = Petq_wrapper, X1 = boost::python::bases<Vasq, mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_>, X2 = boost::noncopyable_::noncopyable, X3 = boost::python::detail::not_specified]' /usr/include/boost/python/class.hpp:244: instantiated from `boost::python::class_<T, X1, X2, X3>& boost::python::class_<T, X1, X2, X3>::def(const char*, A1, const A2&) [with A1 = void (Vasq::*)(), A2 = void (Petq_wrapper::*)(), W = Petq_wrapper, X1 = boost::python::bases<Vasq, mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_, mpl_::void_>, X2 = boost::noncopyable_::noncopyable, X3 = boost::python::detail::not_specified]' test.cxx:52: instantiated from here /usr/include/boost/python/class.hpp:146: error: pointer to member conversion via virtual base `Vasq'
Attachments (4)
Change History (6)
by , 14 years ago
by , 14 years ago
by , 14 years ago
Attachment: | virtual_inheritance.cpp added |
---|
by , 14 years ago
Attachment: | virtual_inheritance_to_be_exported.hpp added |
---|
comment:1 by , 14 years ago
comment:2 by , 13 years ago
Summary: | Failed to wrap classes with virtual inheritance → [fix in git] Failed to wrap classes with virtual inheritance |
---|
Fix here:
http://gitorious.org/~straszheim/boost/straszheim/commit/ce46ee7984344e32983330d5bc4b910002d1cdcc
Instead of checking the virtual function by constructing the function we're passed (which isn't possible), we just check if it will be possible out in type_traits and function_types land.
This fix will make its way back up to svn trunk eventually.
The bug description:
The user has two classes:
struct base{
};
struct derived : virtual public base {};
and exposes them using the following code:
namespace bp = boost::python;
struct base_wrapper : base, bp::wrapper< base > {
};
struct derived_wrapper : derived, bp::wrapper< derived > {
};
BOOST_PYTHON_MODULE(virtual_inheritance){
)(&derived_wrapper::default_do_smth) ); compiler complains to this line }
GCC 4.1.3 and MSVC 7.1 complain on the last line. If the user removes "virtual" from inheritance everything works fine.
In the past, a bug similar to this one was already fixed: http://mail.python.org/pipermail/cplusplus-sig/2003-September/005197.html
I also attach source code and generated code. It is pretty close to "minimum".