[Boost-bugs] [Boost C++ Libraries] #4003: Error in destroy.hpp when methods "T()" and "operator~()" are defined.

Subject: [Boost-bugs] [Boost C++ Libraries] #4003: Error in destroy.hpp when methods "T()" and "operator~()" are defined.
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-03-13 18:16:03


#4003: Error in destroy.hpp when methods "T()" and "operator~()" are defined.
------------------------------------------------------+---------------------
 Reporter: Christopher Bruns <cmbruns@…> | Owner: dave
     Type: Bugs | Status: new
Milestone: Boost 1.43.0 | Component: Python
  Version: Boost 1.42.0 | Severity: Problem
 Keywords: |
------------------------------------------------------+---------------------
 I am wrapping a large library using boost python and Py++. I encountered
 a peculiar situation with one of the wrapped classes.

 I have attached a minimal example and an imperfect patch (see below).

 The problem occurs on line 33 of boost/python/detail/destroy.hpp:


 {{{
 unpatched version:
 =================
 30 template <class T>
 31 static void execute(T const volatile* p)
 32 {
 33 p->T::~T();
 34 }

 }}}

 The problem is that the class being wrapped has a member function "T()",
 and the class returned by that function has an "operator~()"; which leads
 to a compile error. I have been working around this for the past year by
 patching the file destroy.hpp to use the name "Type" instead of "T" in
 this section, each time I install a new version of boost.


 {{{
 patched version:
 ===============
 30 template <class Type>
 31 static void execute(Type const volatile* p)
 32 {
 33 p->Type::~Type();
 34 }
 }}}


 That's not a complete solution, of course. I suspect I could concoct
 another scenario with classes that have a "Type" method etc. But it
 solves the problem for me with the libraries I am actually wrapping.
 Perhaps you C++ gurus could come up with a more robust approach.

 With the patch in place, my module compiles. Without the patch, I get
 these compiler messages:

 #############################################################
 building 'foo_module' extension
 C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox
 /MD /W3 /GS - /DNDEBUG "-IC:/Program
 Files/boost/boost_1_42" -I. -Ic:\Python26\include -Ic:\Pytho
 n26\PC /Tpwrap_foo.cpp /Fobuild\temp.win32-2.6\Release\wrap_foo.obj /EHsc
 -D"_HAS_TR1 =0"
 wrap_foo.cpp
 C:/Program Files/boost/boost_1_42\boost/python/detail/destroy.hpp(33) :
 error C2523: 'Foo3::~T' : destructor tag mismatch
         C:/Program
 Files/boost/boost_1_42\boost/python/detail/destroy.hpp(95) : see reference
 to function template instantiation 'void
 boost::python::detail::value_destroyer<false>::execute<const T>(volatile
 const T *)' being compiled
         with
         [
             T=const Foo3
         ]
         C:/Program
 Files/boost/boost_1_42\boost/python/detail/destroy.hpp(101) : see
 reference to function template instantiation 'void
 boost::python::detail::destroy_referent_impl<T>(void *,T &(__cdecl
 *)(void))' being compiled
         with
         [
             T=const Foo3
         ]
         C:/Program
 Files/boost/boost_1_42\boost/python/converter/rvalue_from_python_data.hpp(135)
 : see reference to function template instantiation 'void
 boost::python::detail::destroy_referent<const Foo3&>(void *,T (__cdecl
 *)(void))' being compiled
         with
         [
             T=const Foo3 &
         ]
         C:/Program
 Files/boost/boost_1_42\boost/python/converter/rvalue_from_python_data.hpp(133)
 : while compiling class template member function
 'boost::python::converter::rvalue_from_python_data<T>::~rvalue_from_python_data(void)'
         with
         [
             T=const Foo3 &
         ]
         C:/Program
 Files/boost/boost_1_42\boost/python/converter/arg_from_python.hpp(124) :
 see reference to class template instantiation
 'boost::python::converter::rvalue_from_python_data<T>' being compiled
         with
         [
             T=const Foo3 &
         ]
         C:/Program
 Files/boost/boost_1_42\boost/python/arg_from_python.hpp(27) : see
 reference to class template instantiation
 'boost::python::converter::arg_rvalue_from_python<T>' being compiled
         with
         [
             T=const Foo3 &
         ]
         C:/Program
 Files/boost/boost_1_42\boost/preprocessor/iteration/detail/local.hpp(37) :
 see reference to class template instantiation
 'boost::python::arg_from_python<T>' being compiled
         with
         [
             T=const Foo3 &
         ]
         C:/Program
 Files/boost/boost_1_42\boost/python/detail/caller.hpp(200) : while
 compiling class template member function 'PyObject
 *boost::python::detail::caller_arity<2>::impl<F,Policies,Sig>::operator
 ()(PyObject *,PyObject *)'
         with
         [
             F=void (__thiscall Foo4::* )(const Foo3 &),
             Policies=boost::python::default_call_policies,
             Sig=boost::mpl::vector3<void,Foo4 &,const Foo3 &>
         ]
         C:/Program
 Files/boost/boost_1_42\boost/python/detail/caller.hpp(169) : see reference
 to class template instantiation
 'boost::python::detail::caller_arity<2>::impl<F,Policies,Sig>' being
 compiled
         with
         [
             F=void (__thiscall Foo4::* )(const Foo3 &),
             Policies=boost::python::default_call_policies,
             Sig=boost::mpl::vector3<void,Foo4 &,const Foo3 &>
         ]
         C:/Program
 Files/boost/boost_1_42\boost/python/make_function.hpp(61) : see reference
 to class template instantiation
 'boost::python::detail::caller<F,CallPolicies,Sig>' being compiled
         with
         [
             F=void (__thiscall Foo4::* )(const Foo3 &),
             CallPolicies=boost::python::default_call_policies,
             Sig=boost::mpl::vector3<void,Foo4 &,const Foo3 &>
         ]
         C:/Program
 Files/boost/boost_1_42\boost/python/make_function.hpp(146) : see reference
 to function template instantiation 'boost::python::api::object
 boost::python::detail::make_function_aux<F,CallPolicies,Signature,boost::mpl::int_<N>>(F,const
 CallPolicies &,const Sig &,const boost::python::detail::keyword_range
 &,NumKeywords)' being compiled
         with
         [
             F=void (__thiscall Foo4::* )(const Foo3 &),
             CallPolicies=boost::python::default_call_policies,
             Signature=boost::mpl::vector3<void,Foo4 &,const Foo3 &>,
             N=1,
             Sig=boost::mpl::vector3<void,Foo4 &,const Foo3 &>,
             NumKeywords=boost::mpl::int_<1>
         ]
         C:/Program Files/boost/boost_1_42\boost/python/class.hpp(544) :
 see reference to function template instantiation
 'boost::python::api::object
 boost::python::make_function<Fn,boost::python::default_call_policies,T1,boost::mpl::vector3<T0,Foo4
 &,T2>>(F,const CallPolicies &,const Keywords &,const Signature &)' being
 compiled
         with
         [
             Fn=void (__thiscall Foo4::* )(const Foo3 &),
             T1=boost::python::detail::keywords<1>,
             T0=void,
             T2=const Foo3 &,
             F=void (__thiscall Foo4::* )(const Foo3 &),
             CallPolicies=boost::python::default_call_policies,
             Keywords=boost::python::detail::keywords<1>,
             Signature=boost::mpl::vector3<void,Foo4 &,const Foo3 &>
         ]
         C:/Program Files/boost/boost_1_42\boost/python/class.hpp(614) :
 see reference to function template instantiation 'void
 boost::python::class_<W>::def_impl<Foo4,Fn,boost::python::detail::def_helper<T1>>(T
 *,const char *,Fn,const Helper &,...)' being compiled
         with
         [
             W=Foo4,
             Fn=void (__thiscall Foo4::* )(const Foo3 &),
             T1=boost::python::detail::keywords<1>,
             T=Foo4,
 Helper=boost::python::detail::def_helper<boost::python::detail::keywords<1>>
         ]
         C:/Program Files/boost/boost_1_42\boost/python/class.hpp(244) :
 see reference to function template instantiation 'void
 boost::python::class_<W>::def_maybe_overloads<A1,A2>(const char *,Fn,const
 boost::python::detail::keywords<1> &,...)' being compiled
         with
         [
             W=Foo4,
             A1=void (__thiscall Foo4::* )(const Foo3 &),
             A2=boost::python::detail::keywords<1>,
             Fn=void (__thiscall Foo4::* )(const Foo3 &)
         ]
         wrap_foo.cpp(21) : see reference to function template
 instantiation 'boost::python::class_<W>
 &boost::python::class_<W>::def<void(__thiscall Foo4::* )(const Foo3
 &),boost::python::detail::keywords<1>>(const char *,A1,const A2 &)' being
 compiled
         with
         [
             W=Foo4,
             A1=void (__thiscall Foo4::* )(const Foo3 &),
             A2=boost::python::detail::keywords<1>
         ]
 error: command '"C:\Program Files\Microsoft Visual Studio
 9.0\VC\BIN\cl.exe"' failed with exit status 2
 #########################################################

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/4003>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:02 UTC