Opened 10 years ago
Closed 9 years ago
#7061 closed Bugs (wontfix)
xcode 4.5 does not compile code which uses boost::statechart
Reported by: | Owned by: | Andreas Huber | |
---|---|---|---|
Milestone: | To Be Determined | Component: | statechart |
Version: | Boost 1.50.0 | Severity: | Showstopper |
Keywords: | Cc: |
Description
The following source code does not compile in XCode 4.5 (it is developer preview 2 version at this moment).
I've got answer from one of the apple guys: "It's a known issue that when using libc++ in C++11 mode, instantiating std::list causes instantiation of the element type more aggressively than other std::list implementations. This probably won't be fixed for Xcode 4.5."
#include <functional> #include <iostream> #include <boost/statechart/state.hpp> #include <boost/statechart/state_machine.hpp> class InitialState; class StateMachine : public boost::statechart::state_machine<StateMachine, InitialState> { public: StateMachine() { } }; class InitialState : public boost::statechart::simple_state<InitialState, StateMachine> { public: InitialState() { } }; int main(int argc, char const* argv[]) { std::cout << "Hello, World!\n"; StateMachine s; return 0; }
Errors are:
In file included from /Users/developer/Downloads/Sandbox/Sandbox/main.cpp:12: In file included from /usr/local/boost_1_50_0/boost/statechart/state.hpp:11: In file included from /usr/local/boost_1_50_0/boost/statechart/simple_state.hpp:13: /usr/local/boost_1_50_0/boost/statechart/detail/leaf_state.hpp:26:27: error: base class has incomplete type class leaf_state : public state_base< Allocator, RttiPolicy > ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Developer4/Xcode45-DP2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/type_traits:1889:54: note: in instantiation of template class 'boost::statechart::detail::leaf_state<std::__1::allocator<void>, boost::statechart::detail::rtti_policy>' requested here decltype(_VSTD::move(_Tp(_VSTD::declval<_Args>()...)), true_type()) ^ /Developer4/Xcode45-DP2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/type_traits:1890:1: note: while substituting deduced template arguments into function template '__is_constructible_test' [with _Tp = std::__1::allocator<std::__1::__list_node<boost::intrusive_ptr<boost::statechart::detail::leaf_state<std::__1::allocator<void>, boost::statechart::detail::rtti_policy>>, void *>>, _Args = <no value>] __is_constructible_test(_Tp&&, _Args&& ...); ^ /Developer4/Xcode45-DP2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/type_traits:1949:14: note: in instantiation of template class 'std::__1::__is_constructible<false, std::__1::allocator<std::__1::__list_node<boost::intrusive_ptr<boost::statechart::detail::leaf_state<std::__1::allocator<void>, boost::statechart::detail::rtti_policy>>, void *>>, std::__1::allocator<std::__1::__list_node<boost::intrusive_ptr<boost::statechart::detail::leaf_state<std::__1::allocator<void>, boost::statechart::detail::rtti_policy>>, void *>> &&>' requested here : public __is_constructible<is_scalar<_Tp>::value || is_reference<_Tp>::value, ^ /Developer4/Xcode45-DP2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/type_traits:1975:14: note: in instantiation of template class 'std::__1::__is_constructible_void_check<false, std::__1::allocator<std::__1::__list_node<boost::intrusive_ptr<boost::statechart::detail::leaf_state<std::__1::allocator<void>, boost::statechart::detail::rtti_policy>>, void *>>, std::__1::allocator<std::__1::__list_node<boost::intrusive_ptr<boost::statechart::detail::leaf_state<std::__1::allocator<void>, boost::statechart::detail::rtti_policy>>, void *>> &&>' requested here : public __is_constructible_void_check<__contains_void<_Tp, _Args...>::value ^ /Developer4/Xcode45-DP2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/type_traits:2455:34: note: in instantiation of template class 'std::__1::is_constructible<std::__1::allocator<std::__1::__list_node<boost::intrusive_ptr<boost::statechart::detail::leaf_state<std::__1::allocator<void>, boost::statechart::detail::rtti_policy>>, void *>>, std::__1::allocator<std::__1::__list_node<boost::intrusive_ptr<boost::statechart::detail::leaf_state<std::__1::allocator<void>, boost::statechart::detail::rtti_policy>>, void *>> &&>' requested here : __is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, _Tp, _Args...> ^ /Developer4/Xcode45-DP2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/type_traits:2590:14: note: (skipping 3 contexts in backtrace; use -ftemplate-backtrace-limit=0 to see all) : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> ^ /Developer4/Xcode45-DP2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/list:513:52: note: in instantiation of template class 'std::__1::__compressed_pair<unsigned long, std::__1::allocator<std::__1::__list_node<boost::intrusive_ptr<boost::statechart::detail::leaf_state<std::__1::allocator<void>, boost::statechart::detail::rtti_policy>>, void *>>>' requested here __compressed_pair<size_type, __node_allocator> __size_alloc_; ^ /Developer4/Xcode45-DP2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/list:770:15: note: in instantiation of template class 'std::__1::__list_imp<boost::intrusive_ptr<boost::statechart::detail::leaf_state<std::__1::allocator<void>, boost::statechart::detail::rtti_policy>>, std::__1::allocator<boost::intrusive_ptr<boost::statechart::detail::leaf_state<std::__1::allocator<void>, boost::statechart::detail::rtti_policy>>>>' requested here : private __list_imp<_Tp, _Alloc> ^ /usr/local/boost_1_50_0/boost/statechart/detail/state_base.hpp:139:16: note: in instantiation of template class 'std::__1::list<boost::intrusive_ptr<boost::statechart::detail::leaf_state<std::__1::allocator<void>, boost::statechart::detail::rtti_policy>>, std::__1::allocator<boost::intrusive_ptr<boost::statechart::detail::leaf_state<std::__1::allocator<void>, boost::statechart::detail::rtti_policy>>>>' requested here typename state_list_type::iterator & statesEnd, ^ /usr/local/boost_1_50_0/boost/statechart/state_machine.hpp:510:22: note: in instantiation of template class 'boost::statechart::detail::state_base<std::__1::allocator<void>, boost::statechart::detail::rtti_policy>' requested here typedef typename state_base_type::node_state_base_ptr_type ^ /Users/developer/Downloads/Sandbox/Sandbox/main.cpp:17:29: note: in instantiation of template class 'boost::statechart::state_machine<StateMachine, InitialState, std::__1::allocator<void>, boost::statechart::null_exception_translator>' requested here class StateMachine : public boost::statechart::state_machine<StateMachine, InitialState> ^ /usr/local/boost_1_50_0/boost/statechart/detail/state_base.hpp:57:7: note: definition of 'boost::statechart::detail::state_base<std::__1::allocator<void>, boost::statechart::detail::rtti_policy>' is not complete until the closing '}' class state_base : ^ In file included from /Users/developer/Downloads/Sandbox/Sandbox/main.cpp:12: In file included from /usr/local/boost_1_50_0/boost/statechart/state.hpp:11: In file included from /usr/local/boost_1_50_0/boost/statechart/simple_state.hpp:13: /usr/local/boost_1_50_0/boost/statechart/detail/leaf_state.hpp:44:44: error: no type named 'iterator' in 'std::__1::list<boost::intrusive_ptr<boost::statechart::detail::leaf_state<std::__1::allocator<void>, boost::statechart::detail::rtti_policy>>, std::__1::allocator<boost::intrusive_ptr<boost::statechart::detail::leaf_state<std::__1::allocator<void>, boost::statechart::detail::rtti_policy>>>>' typename base_type::state_list_type::iterator listPosition ) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~ /usr/local/boost_1_50_0/boost/statechart/detail/leaf_state.hpp:53:44: error: no type named 'iterator' in 'std::__1::list<boost::intrusive_ptr<boost::statechart::detail::leaf_state<std::__1::allocator<void>, boost::statechart::detail::rtti_policy>>, std::__1::allocator<boost::intrusive_ptr<boost::statechart::detail::leaf_state<std::__1::allocator<void>, boost::statechart::detail::rtti_policy>>>>' typename base_type::state_list_type::iterator & statesEnd, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~ /usr/local/boost_1_50_0/boost/statechart/detail/leaf_state.hpp:73:42: error: no type named 'iterator' in 'std::__1::list<boost::intrusive_ptr<boost::statechart::detail::leaf_state<std::__1::allocator<void>, boost::statechart::detail::rtti_policy>>, std::__1::allocator<boost::intrusive_ptr<boost::statechart::detail::leaf_state<std::__1::allocator<void>, boost::statechart::detail::rtti_policy>>>>' typename base_type::state_list_type::iterator listPosition_; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~ In file included from /Users/developer/Downloads/Sandbox/Sandbox/main.cpp:12: In file included from /usr/local/boost_1_50_0/boost/statechart/state.hpp:11: /usr/local/boost_1_50_0/boost/statechart/simple_state.hpp:505:27: error: no type named 'direct_state_base_ptr_type' in 'boost::statechart::detail::rtti_policy::rtti_derived_type<InitialState, boost::statechart::detail::leaf_state<std::__1::allocator<void>, boost::statechart::detail::rtti_policy>>' typename base_type::direct_state_base_ptr_type & pSelf, ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/developer/Downloads/Sandbox/Sandbox/main.cpp:25:29: note: in instantiation of template class 'boost::statechart::simple_state<InitialState, StateMachine, boost::mpl::list<mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, 0>' requested here class InitialState : public boost::statechart::simple_state<InitialState, StateMachine> ^ In file included from /Users/developer/Downloads/Sandbox/Sandbox/main.cpp:12: In file included from /usr/local/boost_1_50_0/boost/statechart/state.hpp:11: In file included from /usr/local/boost_1_50_0/boost/statechart/simple_state.hpp:11: In file included from /usr/local/boost_1_50_0/boost/statechart/event.hpp:11: In file included from /usr/local/boost_1_50_0/boost/statechart/event_base.hpp:15: In file included from /usr/local/boost_1_50_0/boost/intrusive_ptr.hpp:16: /usr/local/boost_1_50_0/boost/smart_ptr/intrusive_ptr.hpp:96:23: error: no matching function for call to 'intrusive_ptr_release' if( px != 0 ) intrusive_ptr_release( px ); ^~~~~~~~~~~~~~~~~~~~~ /Developer4/Xcode45-DP2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/memory:1621:23: note: in instantiation of member function 'boost::intrusive_ptr<boost::statechart::detail::leaf_state<std::__1::allocator<void>, boost::statechart::detail::rtti_policy> >::~intrusive_ptr' requested here __p->~_Tp(); ^ /Developer4/Xcode45-DP2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/memory:1522:14: note: in instantiation of function template specialization 'std::__1::allocator_traits<std::__1::allocator<std::__1::__list_node<boost::intrusive_ptr<boost::statechart::detail::leaf_state<std::__1::allocator<void>, boost::statechart::detail::rtti_policy>>, void *>> >::__destroy<boost::intrusive_ptr<boost::statechart::detail::leaf_state<std::__1::allocator<void>, boost::statechart::detail::rtti_policy>> >' requested here {__destroy(__has_destroy<allocator_type, _Tp*>(), __a, __p);} ^ /Developer4/Xcode45-DP2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/list:685:34: note: in instantiation of function template specialization 'std::__1::allocator_traits<std::__1::allocator<std::__1::__list_node<boost::intrusive_ptr<boost::statechart::detail::leaf_state<std::__1::allocator<void>, boost::statechart::detail::rtti_policy>>, void *>> >::destroy<boost::intrusive_ptr<boost::statechart::detail::leaf_state<std::__1::allocator<void>, boost::statechart::detail::rtti_policy>> >' requested here __node_alloc_traits::destroy(__na, _VSTD::addressof(__n.__value_)); ^ /Developer4/Xcode45-DP2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/list:664:5: note: in instantiation of member function 'std::__1::__list_imp<boost::intrusive_ptr<boost::statechart::detail::leaf_state<std::__1::allocator<void>, boost::statechart::detail::rtti_policy>>, std::__1::allocator<boost::intrusive_ptr<boost::statechart::detail::leaf_state<std::__1::allocator<void>, boost::statechart::detail::rtti_policy>>> >::clear' requested here clear(); ^ /Developer4/Xcode45-DP2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/list:769:23: note: in instantiation of member function 'std::__1::__list_imp<boost::intrusive_ptr<boost::statechart::detail::leaf_state<std::__1::allocator<void>, boost::statechart::detail::rtti_policy>>, std::__1::allocator<boost::intrusive_ptr<boost::statechart::detail::leaf_state<std::__1::allocator<void>, boost::statechart::detail::rtti_policy>>> >::~__list_imp' requested here class _LIBCPP_VISIBLE list ^ /Users/developer/Downloads/Sandbox/Sandbox/main.cpp:20:5: note: in instantiation of member function 'boost::statechart::state_machine<StateMachine, InitialState, std::__1::allocator<void>, boost::statechart::null_exception_translator>::state_machine' requested here StateMachine() ^ /usr/local/boost_1_50_0/boost/statechart/detail/state_base.hpp:165:13: note: candidate template ignored: failed template argument deduction inline void intrusive_ptr_release( ^ 6 errors generated.
So, it looks like it became boost's problem. Any help?
Change History (6)
comment:1 by , 10 years ago
comment:2 by , 10 years ago
Thank you for your answer. I have unsuccessfully tried to reproduce this issue by creating a short piece of C++ code, which does not use any boost code at all. As you have investigated this problem, could you please provide such an example? Thanks.
comment:3 by , 10 years ago
The problem also exists in xcode 4.4 version which is production version, not beta or DP.
comment:4 by , 10 years ago
JFYI, I have tracked down boost src code to this:
#include <list> template <class Alloc> class leaf; template<class Alloc> class base { public: typedef std::list<leaf<Alloc>> list_type; void remove(typename list_type::iterator & stateEnd) {}; }; template <class Alloc> class leaf : public base<Alloc> { }; class Null {}; typedef base<Null>::list_type list_type; int main(int argc, const char * argv[]) { return 0; }
comment:5 by , 10 years ago
Just tested this with both the clang that comes with Xcode 4.5.1 [ aka Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn) ] and clang built from sources this morning [ aka clang version 3.2 (trunk 167013) ]
Failed on Apple's clang - but only with libc++
Worked on TOT clang
comment:6 by , 9 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
XCode defect, see previous comments.
In the state_base type, I'm forward-declaring types that ultimately derive from state_base. This is a circular dependency, so the declarations for these types cannot be simply #included. In state_base, I'm also declaring a std::list typedef, which is then used as a by-reference parameter of a pure-virtual function. It seems that XCode for some reason tries to call functions of the element type at this point. Note that state_base does not call any std::list functions so I'm not really sure why XCodes std::list implementation would try to call any functions on the element type.
To cut a long story short, I don't think there's an easy workaround for this. Moreover, the response from the "apple guys" seems to suggest that this problem is caused by a *defect* in the XCode std library.