Boost C++ Libraries: Ticket #7061: xcode 4.5 does not compile code which uses boost::statechart https://svn.boost.org/trac10/ticket/7061 <p> The following source code does not compile in XCode 4.5 (it is developer preview 2 version at this moment). </p> <p> 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." </p> <pre class="wiki">#include &lt;functional&gt; #include &lt;iostream&gt; #include &lt;boost/statechart/state.hpp&gt; #include &lt;boost/statechart/state_machine.hpp&gt; class InitialState; class StateMachine : public boost::statechart::state_machine&lt;StateMachine, InitialState&gt; { public: StateMachine() { } }; class InitialState : public boost::statechart::simple_state&lt;InitialState, StateMachine&gt; { public: InitialState() { } }; int main(int argc, char const* argv[]) { std::cout &lt;&lt; "Hello, World!\n"; StateMachine s; return 0; } </pre><p> Errors are: </p> <pre class="wiki">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&lt; Allocator, RttiPolicy &gt; ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /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&lt;std::__1::allocator&lt;void&gt;, boost::statechart::detail::rtti_policy&gt;' requested here decltype(_VSTD::move(_Tp(_VSTD::declval&lt;_Args&gt;()...)), 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&lt;std::__1::__list_node&lt;boost::intrusive_ptr&lt;boost::statechart::detail::leaf_state&lt;std::__1::allocator&lt;void&gt;, boost::statechart::detail::rtti_policy&gt;&gt;, void *&gt;&gt;, _Args = &lt;no value&gt;] __is_constructible_test(_Tp&amp;&amp;, _Args&amp;&amp; ...); ^ /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&lt;false, std::__1::allocator&lt;std::__1::__list_node&lt;boost::intrusive_ptr&lt;boost::statechart::detail::leaf_state&lt;std::__1::allocator&lt;void&gt;, boost::statechart::detail::rtti_policy&gt;&gt;, void *&gt;&gt;, std::__1::allocator&lt;std::__1::__list_node&lt;boost::intrusive_ptr&lt;boost::statechart::detail::leaf_state&lt;std::__1::allocator&lt;void&gt;, boost::statechart::detail::rtti_policy&gt;&gt;, void *&gt;&gt; &amp;&amp;&gt;' requested here : public __is_constructible&lt;is_scalar&lt;_Tp&gt;::value || is_reference&lt;_Tp&gt;::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&lt;false, std::__1::allocator&lt;std::__1::__list_node&lt;boost::intrusive_ptr&lt;boost::statechart::detail::leaf_state&lt;std::__1::allocator&lt;void&gt;, boost::statechart::detail::rtti_policy&gt;&gt;, void *&gt;&gt;, std::__1::allocator&lt;std::__1::__list_node&lt;boost::intrusive_ptr&lt;boost::statechart::detail::leaf_state&lt;std::__1::allocator&lt;void&gt;, boost::statechart::detail::rtti_policy&gt;&gt;, void *&gt;&gt; &amp;&amp;&gt;' requested here : public __is_constructible_void_check&lt;__contains_void&lt;_Tp, _Args...&gt;::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&lt;std::__1::allocator&lt;std::__1::__list_node&lt;boost::intrusive_ptr&lt;boost::statechart::detail::leaf_state&lt;std::__1::allocator&lt;void&gt;, boost::statechart::detail::rtti_policy&gt;&gt;, void *&gt;&gt;, std::__1::allocator&lt;std::__1::__list_node&lt;boost::intrusive_ptr&lt;boost::statechart::detail::leaf_state&lt;std::__1::allocator&lt;void&gt;, boost::statechart::detail::rtti_policy&gt;&gt;, void *&gt;&gt; &amp;&amp;&gt;' requested here : __is_nothrow_constructible&lt;is_constructible&lt;_Tp, _Args...&gt;::value, _Tp, _Args...&gt; ^ /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&lt;_Tp, typename add_rvalue_reference&lt;_Tp&gt;::type&gt; ^ /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&lt;unsigned long, std::__1::allocator&lt;std::__1::__list_node&lt;boost::intrusive_ptr&lt;boost::statechart::detail::leaf_state&lt;std::__1::allocator&lt;void&gt;, boost::statechart::detail::rtti_policy&gt;&gt;, void *&gt;&gt;&gt;' requested here __compressed_pair&lt;size_type, __node_allocator&gt; __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&lt;boost::intrusive_ptr&lt;boost::statechart::detail::leaf_state&lt;std::__1::allocator&lt;void&gt;, boost::statechart::detail::rtti_policy&gt;&gt;, std::__1::allocator&lt;boost::intrusive_ptr&lt;boost::statechart::detail::leaf_state&lt;std::__1::allocator&lt;void&gt;, boost::statechart::detail::rtti_policy&gt;&gt;&gt;&gt;' requested here : private __list_imp&lt;_Tp, _Alloc&gt; ^ /usr/local/boost_1_50_0/boost/statechart/detail/state_base.hpp:139:16: note: in instantiation of template class 'std::__1::list&lt;boost::intrusive_ptr&lt;boost::statechart::detail::leaf_state&lt;std::__1::allocator&lt;void&gt;, boost::statechart::detail::rtti_policy&gt;&gt;, std::__1::allocator&lt;boost::intrusive_ptr&lt;boost::statechart::detail::leaf_state&lt;std::__1::allocator&lt;void&gt;, boost::statechart::detail::rtti_policy&gt;&gt;&gt;&gt;' requested here typename state_list_type::iterator &amp; 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&lt;std::__1::allocator&lt;void&gt;, boost::statechart::detail::rtti_policy&gt;' 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&lt;StateMachine, InitialState, std::__1::allocator&lt;void&gt;, boost::statechart::null_exception_translator&gt;' requested here class StateMachine : public boost::statechart::state_machine&lt;StateMachine, InitialState&gt; ^ /usr/local/boost_1_50_0/boost/statechart/detail/state_base.hpp:57:7: note: definition of 'boost::statechart::detail::state_base&lt;std::__1::allocator&lt;void&gt;, boost::statechart::detail::rtti_policy&gt;' 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&lt;boost::intrusive_ptr&lt;boost::statechart::detail::leaf_state&lt;std::__1::allocator&lt;void&gt;, boost::statechart::detail::rtti_policy&gt;&gt;, std::__1::allocator&lt;boost::intrusive_ptr&lt;boost::statechart::detail::leaf_state&lt;std::__1::allocator&lt;void&gt;, boost::statechart::detail::rtti_policy&gt;&gt;&gt;&gt;' 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&lt;boost::intrusive_ptr&lt;boost::statechart::detail::leaf_state&lt;std::__1::allocator&lt;void&gt;, boost::statechart::detail::rtti_policy&gt;&gt;, std::__1::allocator&lt;boost::intrusive_ptr&lt;boost::statechart::detail::leaf_state&lt;std::__1::allocator&lt;void&gt;, boost::statechart::detail::rtti_policy&gt;&gt;&gt;&gt;' typename base_type::state_list_type::iterator &amp; statesEnd, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~ /usr/local/boost_1_50_0/boost/statechart/detail/leaf_state.hpp:73:42: error: no type named 'iterator' in 'std::__1::list&lt;boost::intrusive_ptr&lt;boost::statechart::detail::leaf_state&lt;std::__1::allocator&lt;void&gt;, boost::statechart::detail::rtti_policy&gt;&gt;, std::__1::allocator&lt;boost::intrusive_ptr&lt;boost::statechart::detail::leaf_state&lt;std::__1::allocator&lt;void&gt;, boost::statechart::detail::rtti_policy&gt;&gt;&gt;&gt;' 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&lt;InitialState, boost::statechart::detail::leaf_state&lt;std::__1::allocator&lt;void&gt;, boost::statechart::detail::rtti_policy&gt;&gt;' typename base_type::direct_state_base_ptr_type &amp; pSelf, ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/developer/Downloads/Sandbox/Sandbox/main.cpp:25:29: note: in instantiation of template class 'boost::statechart::simple_state&lt;InitialState, StateMachine, boost::mpl::list&lt;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&gt;, 0&gt;' requested here class InitialState : public boost::statechart::simple_state&lt;InitialState, StateMachine&gt; ^ 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&lt;boost::statechart::detail::leaf_state&lt;std::__1::allocator&lt;void&gt;, boost::statechart::detail::rtti_policy&gt; &gt;::~intrusive_ptr' requested here __p-&gt;~_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&lt;std::__1::allocator&lt;std::__1::__list_node&lt;boost::intrusive_ptr&lt;boost::statechart::detail::leaf_state&lt;std::__1::allocator&lt;void&gt;, boost::statechart::detail::rtti_policy&gt;&gt;, void *&gt;&gt; &gt;::__destroy&lt;boost::intrusive_ptr&lt;boost::statechart::detail::leaf_state&lt;std::__1::allocator&lt;void&gt;, boost::statechart::detail::rtti_policy&gt;&gt; &gt;' requested here {__destroy(__has_destroy&lt;allocator_type, _Tp*&gt;(), __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&lt;std::__1::allocator&lt;std::__1::__list_node&lt;boost::intrusive_ptr&lt;boost::statechart::detail::leaf_state&lt;std::__1::allocator&lt;void&gt;, boost::statechart::detail::rtti_policy&gt;&gt;, void *&gt;&gt; &gt;::destroy&lt;boost::intrusive_ptr&lt;boost::statechart::detail::leaf_state&lt;std::__1::allocator&lt;void&gt;, boost::statechart::detail::rtti_policy&gt;&gt; &gt;' 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&lt;boost::intrusive_ptr&lt;boost::statechart::detail::leaf_state&lt;std::__1::allocator&lt;void&gt;, boost::statechart::detail::rtti_policy&gt;&gt;, std::__1::allocator&lt;boost::intrusive_ptr&lt;boost::statechart::detail::leaf_state&lt;std::__1::allocator&lt;void&gt;, boost::statechart::detail::rtti_policy&gt;&gt;&gt; &gt;::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&lt;boost::intrusive_ptr&lt;boost::statechart::detail::leaf_state&lt;std::__1::allocator&lt;void&gt;, boost::statechart::detail::rtti_policy&gt;&gt;, std::__1::allocator&lt;boost::intrusive_ptr&lt;boost::statechart::detail::leaf_state&lt;std::__1::allocator&lt;void&gt;, boost::statechart::detail::rtti_policy&gt;&gt;&gt; &gt;::~__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&lt;StateMachine, InitialState, std::__1::allocator&lt;void&gt;, boost::statechart::null_exception_translator&gt;::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. </pre><p> So, it looks like it became boost's problem. Any help? </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7061 Trac 1.4.3 Andreas Huber Mon, 09 Jul 2012 08:03:44 GMT <link>https://svn.boost.org/trac10/ticket/7061#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7061#comment:1</guid> <description> <p> 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. </p> <p> 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. </p> </description> <category>Ticket</category> </item> <item> <author>Anton Bychkov <bychkov.anton@…></author> <pubDate>Thu, 19 Jul 2012 07:53:41 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7061#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7061#comment:2</guid> <description> <p> 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. </p> </description> <category>Ticket</category> </item> <item> <author>Anton Bychkov <bychkov.anton@…></author> <pubDate>Tue, 31 Jul 2012 07:53:06 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7061#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7061#comment:3</guid> <description> <p> The problem also exists in xcode 4.4 version which is production version, not beta or DP. </p> </description> <category>Ticket</category> </item> <item> <author>Anton Bychkov <bychkov.anton@…></author> <pubDate>Tue, 31 Jul 2012 10:06:48 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7061#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7061#comment:4</guid> <description> <p> JFYI, I have tracked down boost src code to this: </p> <pre class="wiki">#include &lt;list&gt; template &lt;class Alloc&gt; class leaf; template&lt;class Alloc&gt; class base { public: typedef std::list&lt;leaf&lt;Alloc&gt;&gt; list_type; void remove(typename list_type::iterator &amp; stateEnd) {}; }; template &lt;class Alloc&gt; class leaf : public base&lt;Alloc&gt; { }; class Null {}; typedef base&lt;Null&gt;::list_type list_type; int main(int argc, const char * argv[]) { return 0; } </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>Marshall Clow</dc:creator> <pubDate>Wed, 31 Oct 2012 16:43:58 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7061#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7061#comment:5</guid> <description> <p> Just tested this with both the clang that comes with Xcode 4.5.1 [ aka <em>Apple clang version 4.1 (tags/Apple/clang-421.11.66) (based on LLVM 3.1svn)</em> ] and clang built from sources this morning [ aka <em>clang version 3.2 (trunk 167013)</em> ] </p> <p> Failed on Apple's clang - but only with libc++ </p> <p> Worked on TOT clang </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Andreas Huber</dc:creator> <pubDate>Sun, 09 Jun 2013 18:08:56 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/7061#comment:6 https://svn.boost.org/trac10/ticket/7061#comment:6 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">wontfix</span> </li> </ul> <p> XCode defect, see previous comments. </p> Ticket