#12969 closed Bugs (fixed)
Problem linking print_helper_t<nullptr_t> under Clang
Reported by: | Owned by: | Raffi Enficiaud | |
---|---|---|---|
Milestone: | Boost 1.67.0 | Component: | test |
Version: | Boost 1.64.0 | Severity: | Problem |
Keywords: | test, link, print_helper_t, nullptr, nullptr_t, 1_64_0_b2 | Cc: |
Description
I'm trying out 1.64.0 b2...
I can get the following code to compile, link and run under GCC :
#define BOOST_TEST_DYN_LINK #include <boost/test/unit_test.hpp> BOOST_AUTO_TEST_CASE( plv_tc ) { BOOST_TEST( nullptr == nullptr ); } bool init_function() { return true; } int main( int argc, char* argv[] ) { return ::boost::unit_test::unit_test_main( &init_function, argc, argv ); }
...with commands:
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
...but if I try with Clang:
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
...I get:
/tmp/boost-test-fe7931.o: In function `std::__1::basic_ostream<char, std::__1::char_traits<char> >& boost::test_tools::tt_detail::operator<< <decltype(nullptr)>(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, boost::test_tools::tt_detail::print_helper_t<decltype(nullptr)> const&)': 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<decltype(nullptr)>::operator()(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, decltype(nullptr))' clang: error: linker command failed with exit code 1 (use -v to see invocation)
I may well just be doing something stupid - apologies if so.
I'm using Clang++ 3.8.1 and GCC 6.2.0 on Ubuntu 16.10 (Linux 4.8.0-46-generic; x86_64).
Change History (9)
comment:1 by , 6 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 5 years ago
comment:3 by , 5 years ago
Thanks, I was not able to reproduce initially the issue, but with the last information I understand better what the issue is.
comment:4 by , 5 years ago
In branch topic/12969-problems-nullptr
. 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.
comment:5 by , 5 years ago
Milestone: | To Be Determined → Boost 1.66.0 |
---|
comment:6 by , 5 years ago
Milestone: | Boost 1.66.0 → Boost 1.67.0 |
---|
comment:9 by , 5 years ago
Thanks very much for this fix.
Apologies - I didn't see the message asking for a check. Yes - that works for me.
AFAUI, what's going on is:
print_log_value<>
fornullptr_t
with a declaration (but not definition) of itsoperator()
.print_log_value<std::nullptr_t>::operator()
.I can work around this. However it may make things a bit simpler to either:
print_log_value<std::nullptr_t>::operator()
in the.hpp
rather than in a separate.ipp
, or failing thatprint_log_value<>
fornullptr_t
at all and leave it for users to do themselves if they wish.