Boost C++ Libraries: Ticket #3183: Compilation fails with many arguments, with default values https://svn.boost.org/trac10/ticket/3183 <p> Hi, I'm using pyplusplus and Boost.Python to wrap a class where one of the member functions has many (28) arguments, most of them with default values. The wrapping code handles the default arguments with the Py++ "do nothing" approach, i.e. not by using the BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS macro. I am using bjam to build my project, and am confident that the code produced by Py++ should compile, because the other member functions with similar (but fewer) arguments and default arguments compile fine. I did have to increase BOOST_PYTHON_MAX_ARITY, and I am sure it is large enough to cover my arguments. I suspect I am running into a compiler limitation because I get a slightly different error message when I remove the -ftemplate-depth-128 flag (the error message appears to be truncated when I have the -ftemplate-depth-18 flag). Here is the essence of the error message, without the -ftemplate-depth-128 flag: </p> <hr /> <p> /data/cmejia/install/boost_1_39_0/boost/python/detail/invoke.hpp: In function `<a class="missing wiki">PyObject</a>* boost::python::detail::invoke(... /data/cmejia/install/boost_1_39_0/boost/python/detail/caller.hpp:223: instantiated from `<a class="missing wiki">PyObject</a>* ... /data/cmejia/install/boost_1_39_0/boost/python/object/py_function.hpp:38: instantiated from `<a class="missing wiki">PyObject</a>* ... dcs.cpp:9: instantiated from here /data/cmejia/install/boost_1_39_0/boost/python/detail/invoke.hpp:75: error: must use .* or -&gt;* to call pointer-to-member function in `f (...)' </p> <hr /> <p> Which doesn't make sense because none of the other code has needed to use .* or -&gt;*. The last 19 arguments to this member function are all doubles, all with default values. If I remove the last 3 doubles from the wrapping code produced by pyplusplus, *and* remove them from the header file I am trying to wrap, I am able to compile successfully. (If I remove them only from my wrapping code, but not from the header file I am trying to wrap, I am unable to compile.) Anyway, this seems to indicate that the compiler is running up against some limit, and I was wondering if there was a flag to set to get past this problem. The current set of compiler flags, from bjam, are "g++" -ftemplate-depth-128 -O0 -fno-inline -Wall -g -fPIC -DBOOST_PYTHON_MAX_ARITY=40 I am using g++ version 3.4.6 on Red Hat Enterprise Linux WS release 4 (Nahant Update 6). Any information would be appreciated. (follow up...): </p> <p> I developed a minimal complete test case exhibiting this problem, contained in the attached files. The compilation command I used was: </p> <p> g++ -DBOOST_PYTHON_MAX_ARITY=40 -I/data/cmejia/install/boost_1_39_0 -I/data/include/python2.6 </p> <blockquote> <p> -c -o foo.o foo.cpp </p> </blockquote> <p> As I explained earlier in the first message of this thread, this fails to compile, but if I remove one double argument towards the end (i.e. edit out one line of foo.hpp and two lines of foo.cpp) it does compile successfully. The file foo.pp is the preprocessed source from "g++ ... -E foo.cpp &gt; foo.pp". I would appreciate any further insight into this problem, and hopefully we can use this test case to make Boost.Python an even better tool. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3183 Trac 1.4.3 Christopher A. Mejia <camejia@…> Tue, 16 Jun 2009 04:06:52 GMT attachment set https://svn.boost.org/trac10/ticket/3183 https://svn.boost.org/trac10/ticket/3183 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">foo.hpp</span> </li> </ul> Ticket Christopher A. Mejia <camejia@…> Tue, 16 Jun 2009 04:07:15 GMT attachment set https://svn.boost.org/trac10/ticket/3183 https://svn.boost.org/trac10/ticket/3183 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">foo.cpp</span> </li> </ul> Ticket Steven Watanabe Wed, 17 Jun 2009 00:45:59 GMT component changed; owner set https://svn.boost.org/trac10/ticket/3183#comment:1 https://svn.boost.org/trac10/ticket/3183#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Dave Abrahams</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">Python</span> </li> </ul> Ticket Steven Watanabe Wed, 17 Jun 2009 00:59:26 GMT <link>https://svn.boost.org/trac10/ticket/3183#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3183#comment:2</guid> <description> <p> The problem appears to be that <a href="http://www.boost.org/libs/type_traits/doc/html/boost_typetraits/reference/is_member_function_pointer.html">boost::is_member_function_pointer</a> has a hard coded limit of 24 arguments. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>troy d. straszheim</dc:creator> <pubDate>Sat, 19 Sep 2009 19:02:33 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/3183#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3183#comment:3</guid> <description> <p> What do we do here? Looks like type traits is at 'fault'... I'm inclined to wontfix. </p> <p> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>troy d. straszheim</dc:creator> <pubDate>Sun, 20 Sep 2009 14:30:07 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/3183#comment:4 https://svn.boost.org/trac10/ticket/3183#comment:4 <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> Here's a workaround: </p> <p> <a class="ext-link" href="http://gitorious.org/~straszheim/boost/straszheim/commit/02776bcf430aa1dd6325c564965bca2a3c11f358"><span class="icon">​</span>http://gitorious.org/~straszheim/boost/straszheim/commit/02776bcf430aa1dd6325c564965bca2a3c11f358</a> </p> Ticket Dave Abrahams Mon, 21 Sep 2009 16:48:08 GMT <link>https://svn.boost.org/trac10/ticket/3183#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3183#comment:5</guid> <description> <p> Hi Troy, </p> <p> Although I think 24 is a reasonable upper bound, and I very much appreciate you posting a workaround, I am wondering if your recent cleanups caused this? A potential downside of re-using other boost components is that we have to adopt their limits. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>troy d. straszheim</dc:creator> <pubDate>Mon, 21 Sep 2009 17:02:08 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/3183#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3183#comment:6</guid> <description> <p> None of my cleanups are in SVN... they couldn't have caused your error. As Steven points out the 'problem' is in type_traits. </p> </description> <category>Ticket</category> </item> </channel> </rss>