Boost C++ Libraries: Ticket #6616: boost preprocessor bug in 1.49 https://svn.boost.org/trac10/ticket/6616 <p> this example work incorrect with boost 1.49 on g++ 4.61 with compile flags -std=gnu++0x<br /> <br /> #define WRITE_TEST_VALUE(r, data, num, name) std::cout &lt;&lt; ", num: " &lt;&lt; num &lt;&lt; ", name: " &lt;&lt; BOOST_PP_STRINGIZE(name);<br /> #define ON_FOREACH_ARGS(<a class="missing wiki">ArgsArray</a>, Functor) \<br /> </p> <blockquote> <p> BOOST_PP_LIST_FOR_EACH_I(Functor, , \<br /> </p> <blockquote> <p> BOOST_PP_TUPLE_TO_LIST(BOOST_PP_ARRAY_SIZE(<a class="missing wiki">ArgsArray</a>), BOOST_PP_ARRAY_DATA(<a class="missing wiki">ArgsArray</a>)))<br /> </p> </blockquote> </blockquote> <p> #define TEST_PP_LIST_FOREACH(<a class="missing wiki">ArgsArray</a>) \<br /> </p> <blockquote> <p> std::cout &lt;&lt; " sz: " &lt;&lt; BOOST_PP_ARRAY_SIZE(<a class="missing wiki">ArgsArray</a>); \<br /> ON_FOREACH_ARGS(<a class="missing wiki">ArgsArray</a>, WRITE_TEST_VALUE)<br /> </p> </blockquote> <p> #include &lt;iostream&gt;<br /> #include &lt;boost/preprocessor/list.hpp&gt;<br /> #include &lt;boost/preprocessor/tuple.hpp&gt;<br /> #include &lt;boost/preprocessor/array.hpp&gt;<br /> #include &lt;boost/preprocessor/stringize.hpp&gt;<br /> <br /> int main()<br /> {<br /> </p> <blockquote> <p> std::cout &lt;&lt; "0:" &lt;&lt; std::endl;<br /> TEST_PP_LIST_FOREACH((0, ()))<br /> std::cout &lt;&lt; std::endl &lt;&lt; "1:" &lt;&lt; std::endl;<br /> TEST_PP_LIST_FOREACH((1, (bla)))<br /> std::cout &lt;&lt; std::endl &lt;&lt; "2:" &lt;&lt; std::endl;<br /> TEST_PP_LIST_FOREACH((2, (nu, bla)))<br /> std::cout &lt;&lt; std::endl;<br /> return 0;<br /> </p> </blockquote> <p> }<br /> <br /> output:<br /> g++ test_pp.cpp -I/home/snike/boost/boost_1_49_0<br /> ./a.out<br /> 0:<br /> sz: 0<br /> 1:<br /> sz: 1, num: 0, name: bla<br /> 2:<br /> sz: 2, num: 0, name: nu, num: 1, name: bla<br /> <br /> output2:<br /> g++ test_pp.cpp -I/home/snike/boost/boost_1_49_0 -std=gnu++0x<br /> ./a.out<br /> 0:<br /> sz: 0, num: 0, name:<br /> 1:<br /> sz: 1, num: 0, name: bla<br /> 2:<br /> sz: 2, num: 0, name: nu, num: 1, name: bla<br /> <br /> on boost 1.48 this example work correctly </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6616 Trac 1.4.3 anonymous Fri, 04 Jan 2013 15:07:09 GMT <link>https://svn.boost.org/trac10/ticket/6616#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6616#comment:1</guid> <description> <p> Yes, the boost preprocessor library changed behavior from 1.48.0 to 1.49.0. </p> <p> For Visual C++ 8.0, preprocessing this code: </p> <div class="wiki-code"><div class="code"><pre><span class="cp">#include</span> <span class="cpf">&lt;boost/preprocessor/tuple/to_list.hpp&gt;</span><span class="cp"></span> <span class="n">BOOST_PP_TUPLE_TO_LIST</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">))</span> <span class="n">BOOST_PP_TUPLE_TO_LIST</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="p">(</span><span class="n">a</span><span class="p">))</span> <span class="n">BOOST_PP_TUPLE_TO_LIST</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="p">())</span> </pre></div></div><p> used to give this output: </p> <div class="wiki-code"><div class="code"><pre><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="n">BOOST_PP_NIL</span><span class="p">))</span> <span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">BOOST_PP_NIL</span><span class="p">)</span> <span class="n">BOOST_PP_NIL</span> </pre></div></div><p> but for 1.49.0 the compiler give these warnings: </p> <p> a.cpp(5) : warning C4003: not enough actual parameters for macro 'BOOST_PP_TUPLE_TO_LIST_1' a.cpp(5) : warning C4003: not enough actual parameters for macro 'BOOST_PP_TUPLE_TO_LIST_1' </p> <p> and this output: </p> <div class="wiki-code"><div class="code"><pre><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="p">(</span><span class="n">b</span><span class="p">,</span> <span class="n">BOOST_PP_NIL</span><span class="p">))</span> <span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">BOOST_PP_NIL</span><span class="p">)</span> <span class="p">(,</span> <span class="n">BOOST_PP_NIL</span><span class="p">)</span> </pre></div></div><p> I have similar problems for BOOST_PP_TUPLE_TO_SEQ() and for Clang 3.1. These problems still exist for the latest version of boost (1.52.0). </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Fri, 04 Jan 2013 15:21:15 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6616#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6616#comment:2</guid> <description> <p> These problems are related to this ticket: <a class="ext-link" href="https://svn.boost.org/trac/boost/ticket/7560"><span class="icon">​</span>https://svn.boost.org/trac/boost/ticket/7560</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Edward Diener</dc:creator> <pubDate>Sun, 17 May 2015 03:27:15 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6616#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6616#comment:3</guid> <description> <p> There is no such thing as a tuple of size 0. Therefore attempting to pass 0 for a tuple size gives undefined behavior. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Edward Diener</dc:creator> <pubDate>Sun, 17 May 2015 03:27:22 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/6616#comment:4 https://svn.boost.org/trac10/ticket/6616#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">fixed</span> </li> </ul> Ticket