Subject: [Boost-bugs] [Boost C++ Libraries] #10684: Implicit conversion warnings when using clang's -Wconversion flag.
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-10-21 21:09:35
#10684: Implicit conversion warnings when using clang's -Wconversion flag.
------------------------------+--------------------------
Reporter: anonymous | Owner: rogeeff
Type: Bugs | Status: new
Milestone: To Be Determined | Component: test
Version: Boost 1.56.0 | Severity: Optimization
Keywords: |
------------------------------+--------------------------
Operating system: OS X 10.10
Compiler:
{{{
$ clang++ --version
Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix
$
}}}
Boost: 1.56.0
The following code (assumed to be in a file named clang_warning.cpp):
{{{
#!c++
// clang_warning.cpp:
#define BOOST_TEST_MODULE Test
#include <boost/test/unit_test.hpp>
BOOST_AUTO_TEST_CASE(test)
{
BOOST_CHECK(true);
}
}}}
when compiled using the -Wconversion flag (and Boost under
/opt/boost_1_56_0/) like:
{{{
$ clang++ -Wconversion -I/opt/boost_1_56_0/ clang_warning.cpp
-lboost_test_exec_monitor
}}}
gives implicit conversion warnings like:
{{{
/opt/boost_1_56_0/boost/test/utils/basic_cstring/bcs_char_traits.hpp:90:20:
warning: implicit conversion changes signedness: 'long' to 'std::size_t'
(aka 'unsigned long') [-Wsign-conversion]
return ptr - cstr;
~~~~~~ ~~~~^~~~~~
}}}
{{{
/opt/boost_1_56_0/boost/test/utils/basic_cstring/basic_cstring.hpp:232:18:
warning: implicit conversion changes signedness: 'long' to 'size_type'
(aka 'unsigned long') [-Wsign-conversion]
return m_end - m_begin;
~~~~~~ ~~~~~~^~~~~~~~~
}}}
{{{
/opt/boost_1_56_0/boost/test/utils/basic_cstring/io.hpp:55:50:
warning: implicit conversion changes signedness: 'long' to 'size_type'
(aka 'unsigned long') [-Wsign-conversion]
os << std::basic_string<CharT1,Tr>( beg, end - beg );
~~~ ~~~~^~~~~
}}}
The full output is below:
{{{
$ clang++ -Wconversion -I/opt/boost_1_56_0/ clang_warning.cpp
-lboost_test_exec_monitor
In file included from clang_warning.cpp:4:
In file included from /opt/boost_1_56_0/boost/test/unit_test.hpp:19:
In file included from /opt/boost_1_56_0/boost/test/test_tools.hpp:19:
In file included from
/opt/boost_1_56_0/boost/test/predicate_result.hpp:21:
In file included from
/opt/boost_1_56_0/boost/test/utils/basic_cstring/basic_cstring.hpp:21:
/opt/boost_1_56_0/boost/test/utils/basic_cstring/bcs_char_traits.hpp:90:20:
warning: implicit conversion changes signedness: 'long' to 'std::size_t'
(aka 'unsigned long') [-Wsign-conversion]
return ptr - cstr;
~~~~~~ ~~~~^~~~~~
/opt/boost_1_56_0/boost/test/utils/basic_cstring/basic_cstring.hpp:182:40:
note: in instantiation of member function
'boost::unit_test::ut_detail::bcs_char_traits_impl<const char>::length'
requested here
, m_end ( m_begin + (s ? traits_type::length( s ) : 0 ) )
^
/opt/boost_1_56_0/boost/test/unit_test_suite_impl.hpp:158:41: note: in
instantiation of member function 'boost::unit_test::basic_cstring<const
char>::basic_cstring' requested here
master_test_suite_t() : test_suite( "Master Test Suite" )
^
In file included from clang_warning.cpp:4:
In file included from /opt/boost_1_56_0/boost/test/unit_test.hpp:19:
In file included from /opt/boost_1_56_0/boost/test/test_tools.hpp:19:
In file included from
/opt/boost_1_56_0/boost/test/predicate_result.hpp:21:
/opt/boost_1_56_0/boost/test/utils/basic_cstring/basic_cstring.hpp:232:18:
warning: implicit conversion changes signedness: 'long' to 'size_type'
(aka 'unsigned long') [-Wsign-conversion]
return m_end - m_begin;
~~~~~~ ~~~~~~^~~~~~~~~
/opt/boost_1_56_0/boost/test/framework.hpp:90:86: note: in instantiation
of member function 'boost::unit_test::basic_cstring<const char>::size'
requested here
internal_error( const_string m ) : std::runtime_error( std::string(
m.begin(), m.size() ) ) {}
^
In file included from clang_warning.cpp:4:
In file included from /opt/boost_1_56_0/boost/test/unit_test.hpp:19:
In file included from /opt/boost_1_56_0/boost/test/test_tools.hpp:28:
/opt/boost_1_56_0/boost/test/utils/basic_cstring/io.hpp:55:50: warning:
implicit conversion changes signedness: 'long' to 'size_type' (aka
'unsigned long') [-Wsign-conversion]
os << std::basic_string<CharT1,Tr>( beg, end - beg );
~~~ ~~~~^~~~~
/opt/boost_1_56_0/boost/test/utils/lazy_ostream.hpp:74:29: note: in
instantiation of function template specialization
'boost::unit_test::operator<<<char, std::__1::char_traits<char>, const
char>' requested here
return m_prev(ostr) << m_value;
^
clang_warning.cpp:8:5: note: in instantiation of member function
'boost::unit_test::lazy_ostream_impl<const
boost::unit_test::basic_cstring<const char> &>::operator()' requested here
BOOST_CHECK(true);
^
/opt/boost_1_56_0/boost/test/test_tools.hpp:110:45: note: expanded from
macro 'BOOST_CHECK'
#define BOOST_CHECK( P ) BOOST_CHECK_IMPL( (P),
BOOST_TEST_STRINGIZE( P ), CHECK, CHECK_PRED )
^
/opt/boost_1_56_0/boost/test/test_tools.hpp:91:5: note: expanded from
macro 'BOOST_CHECK_IMPL'
BOOST_TEST_TOOL_IMPL( check_impl, P, check_descr, TL, CT ), 0 );\
^
/opt/boost_1_56_0/boost/test/test_tools.hpp:79:9: note: expanded from
macro 'BOOST_TEST_TOOL_IMPL'
::boost::unit_test::lazy_ostream::instance() << check_descr, \
^
3 warnings generated.
$
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/10684> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:17 UTC