Boost C++ Libraries: Ticket #12969: Problem linking print_helper_t<nullptr_t> under Clang https://svn.boost.org/trac10/ticket/12969 <p> I'm trying out 1.64.0 b2... </p> <p> I can get the following code to compile, link and run under GCC : </p> <div class="wiki-code"><div class="code"><pre><span class="cp">#define BOOST_TEST_DYN_LINK</span> <span class="cp">#include</span> <span class="cpf">&lt;boost/test/unit_test.hpp&gt;</span><span class="cp"></span> <span class="n">BOOST_AUTO_TEST_CASE</span><span class="p">(</span> <span class="n">plv_tc</span> <span class="p">)</span> <span class="p">{</span> <span class="n">BOOST_TEST</span><span class="p">(</span> <span class="k">nullptr</span> <span class="o">==</span> <span class="k">nullptr</span> <span class="p">);</span> <span class="p">}</span> <span class="kt">bool</span> <span class="n">init_function</span><span class="p">()</span> <span class="p">{</span> <span class="k">return</span> <span class="nb">true</span><span class="p">;</span> <span class="p">}</span> <span class="kt">int</span> <span class="n">main</span><span class="p">(</span> <span class="kt">int</span> <span class="n">argc</span><span class="p">,</span> <span class="kt">char</span><span class="o">*</span> <span class="n">argv</span><span class="p">[]</span> <span class="p">)</span> <span class="p">{</span> <span class="k">return</span> <span class="o">::</span><span class="n">boost</span><span class="o">::</span><span class="n">unit_test</span><span class="o">::</span><span class="n">unit_test_main</span><span class="p">(</span> <span class="o">&amp;</span><span class="n">init_function</span><span class="p">,</span> <span class="n">argc</span><span class="p">,</span> <span class="n">argv</span> <span class="p">);</span> <span class="p">}</span> </pre></div></div><p> ...with commands: </p> <pre class="wiki">setenv BOOST_ROOT /opt/boost_1_64_0_b2_gcc_build setenv LD_LIBRARY_PATH $BOOST_ROOT/lib g++ -std=c++11 -isystem $BOOST_ROOT/include boost-test.nullptr-problem.cpp -L$BOOST_ROOT/lib -lboost_unit_test_framework-mt ./a.out </pre><p> ...but if I try with Clang: </p> <pre class="wiki">setenv BOOST_ROOT /opt/boost_1_64_0_b2_clang_build setenv LD_LIBRARY_PATH $BOOST_ROOT/lib clang++ -std=c++11 -stdlib=libc++ -isystem $BOOST_ROOT/include boost-test.nullptr-problem.cpp -L$BOOST_ROOT/lib -lboost_unit_test_framework-mt </pre><p> ...I get: </p> <pre class="wiki">/tmp/boost-test-fe7931.o: In function `std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp; boost::test_tools::tt_detail::operator&lt;&lt; &lt;decltype(nullptr)&gt;(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;, boost::test_tools::tt_detail::print_helper_t&lt;decltype(nullptr)&gt; const&amp;)': boost-test.nullptr-problem.cpp:(.text._ZN5boost10test_tools9tt_detaillsIDnEERNSt3__113basic_ostreamIcNS3_11char_traitsIcEEEES8_RKNS1_14print_helper_tIT_EE[_ZN5boost10test_tools9tt_detaillsIDnEERNSt3__113basic_ostreamIcNS3_11char_traitsIcEEEES8_RKNS1_14print_helper_tIT_EE]+0x26): undefined reference to `boost::test_tools::tt_detail::print_log_value&lt;decltype(nullptr)&gt;::operator()(std::__1::basic_ostream&lt;char, std::__1::char_traits&lt;char&gt; &gt;&amp;, decltype(nullptr))' clang: error: linker command failed with exit code 1 (use -v to see invocation) </pre><p> I may well just be doing something stupid - apologies if so. </p> <p> I'm using Clang++ 3.8.1 and GCC 6.2.0 on Ubuntu 16.10 (Linux 4.8.0-46-generic; x86_64). </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12969 Trac 1.4.3 Raffi Enficiaud Sun, 16 Apr 2017 20:31:26 GMT owner, status changed https://svn.boost.org/trac10/ticket/12969#comment:1 https://svn.boost.org/trac10/ticket/12969#comment:1 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Gennadiy Rozental</span> to <span class="trac-author">Raffi Enficiaud</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket Tony E Lewis <TonyELewis@…> Fri, 17 Nov 2017 10:13:48 GMT <link>https://svn.boost.org/trac10/ticket/12969#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12969#comment:2</guid> <description> <p> AFAUI, what's going on is: </p> <ul><li>I'm building my code in C++14 mode, which causes the Boost Test code to provide a specialisation of <code>print_log_value&lt;&gt;</code> for <code>nullptr_t</code> with a declaration (but not definition) of its <code>operator()</code>. </li><li>I'm linking against Boost libraries that were built without any standard specified. In GCC 7.2.0 means ~C++14 but in Clang 4.0.1 means ~C++03. So the Clang-built library I'm linking against doesn't provide any definition of <code>print_log_value&lt;std::nullptr_t&gt;::operator()</code>. </li></ul><p> I can work around this. However it may make things a bit simpler to either: </p> <ul><li>provide an inline definition of <code>print_log_value&lt;std::nullptr_t&gt;::operator()</code> in the <code>.hpp</code> rather than in a separate <code>.ipp</code>, or failing that </li><li>not specialise <code>print_log_value&lt;&gt;</code> for <code>nullptr_t</code> at all and leave it for users to do themselves if they wish. </li></ul> </description> <category>Ticket</category> </item> <item> <dc:creator>Raffi Enficiaud</dc:creator> <pubDate>Sat, 30 Dec 2017 09:38:13 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/12969#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12969#comment:3</guid> <description> <p> Thanks, I was not able to reproduce initially the issue, but with the last information I understand better what the issue is. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Raffi Enficiaud</dc:creator> <pubDate>Sat, 30 Dec 2017 09:46:05 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/12969#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12969#comment:4</guid> <description> <p> In branch <code>topic/12969-problems-nullptr</code>. It would be good if you tell me if this fixes your issue, as it is not possible to have a unit test covering this. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Raffi Enficiaud</dc:creator> <pubDate>Tue, 02 Jan 2018 20:46:16 GMT</pubDate> <title>milestone changed https://svn.boost.org/trac10/ticket/12969#comment:5 https://svn.boost.org/trac10/ticket/12969#comment:5 <ul> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.66.0</span> </li> </ul> Ticket Raffi Enficiaud Wed, 17 Jan 2018 19:52:33 GMT milestone changed https://svn.boost.org/trac10/ticket/12969#comment:6 https://svn.boost.org/trac10/ticket/12969#comment:6 <ul> <li><strong>milestone</strong> <span class="trac-field-old">Boost 1.66.0</span> → <span class="trac-field-new">Boost 1.67.0</span> </li> </ul> Ticket Raffi Enficiaud Fri, 19 Jan 2018 13:43:10 GMT <link>https://svn.boost.org/trac10/ticket/12969#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12969#comment:7</guid> <description> <p> On develop </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Raffi Enficiaud</dc:creator> <pubDate>Mon, 22 Jan 2018 13:06:13 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/12969#comment:8 https://svn.boost.org/trac10/ticket/12969#comment:8 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> On master </p> Ticket Tony E Lewis <tonyelewis@…> Tue, 23 Jan 2018 14:06:07 GMT <link>https://svn.boost.org/trac10/ticket/12969#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12969#comment:9</guid> <description> <p> Thanks very much for this fix. </p> <p> Apologies - I didn't see the message asking for a check. Yes - that works for me. </p> </description> <category>Ticket</category> </item> </channel> </rss>