Opened 9 years ago

Closed 4 years ago

#8991 closed Bugs (fixed)

A few implicit conversion compiler warnings

Reported by: Jan Bouwer <JBouwer@…> Owned by: Antony Polukhin
Milestone: Boost 1.69 Component: lexical_cast
Version: Boost 1.54.0 Severity: Cosmetic
Keywords: Cc:

Description

The following (trivial?) warnings were kindly highlighted by clang (version) - using diagnostic options as indicated in the [...].

File locations are in the format path:line:byte-column. I based these on the 1.54.0 release, as svn rev. 85329 did not compile for me at the time.

  • boost/lexical_cast.hpp:1693:50

warning: implicit conversion changes signedness: 'long' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]

                end = begin + swprintf(begin, end-begin,
                              ~~~~~~~~        ~~~^~~~~~

  • boost/lexical_cast.hpp:1703:50

warning: implicit conversion changes signedness: 'long' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]

                end = begin + swprintf(begin, end-begin,
                              ~~~~~~~~        ~~~^~~~~~
  • boost/lexical_cast.hpp:1711:50

warning: implicit conversion changes signedness: 'long' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]

                end = begin + swprintf(begin, end-begin,
                              ~~~~~~~~        ~~~^~~~~~
  • boost/lexical_cast.hpp:791:68

warning: operand of ? changes signedness: 'int' to 'unsigned int' & 'long' to 'unsigned long' [-Wsign-conversion]

                value < 0 ? 0u - static_cast<result_type>(value) : value
                                                                   ^~~~~

from:

boost/lexical_cast.hpp:1627:52: note: in instantiation of function template specialization 'boost::detail::lcast_to_unsigned<int>' requested here
                start = lcast_put_unsigned<Traits>(lcast_to_unsigned(n), finish);
                                                   ^
boost/lexical_cast.hpp:1816:66: note: in instantiation of function template specialization 'boost::detail::lexical_stream_limited_src<char, std::__1::char_traits<char>, false>::shl_signed<int>' requested here
            bool operator<<(int n)                      { return shl_signed(n); }
                                                                 ^

and

boost/lexical_cast.hpp:1627:52: note: in instantiation of function template specialization 'boost::detail::lcast_to_unsigned<long>' requested here
                start = lcast_put_unsigned<Traits>(lcast_to_unsigned(n), finish);
                                                   ^
boost/lexical_cast.hpp:1817:66: note: in instantiation of function template specialization 'boost::detail::lexical_stream_limited_src<char, std::__1::char_traits<char>, false>::shl_signed<long>' requested here
            bool operator<<(long n)                     { return shl_signed(n); }
  • boost/lexical_cast.hpp:1962:30

warning: implicit conversion changes signedness: 'utype' (aka 'unsigned int') to 'int' [-Wsign-conversion]

                    output = out_tmp;
                           ~ ^~~~~~~
boost/lexical_cast.hpp:2032:74: note: in instantiation of function template specialization 'boost::detail::lexical_stream_limited_src<char, std::__1::char_traits<char>, false>::shr_signed<int>' requested here
            bool operator>>(int& output)                        { return shr_signed(output); }
                                                                         ^

"clang --version"

Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin12.4.0
Thread model: posix

Change History (2)

comment:1 by Antony Polukhin, 9 years ago

(In [86750]) Fix some of the implicit conversion warnings (refs #8991)

comment:2 by Antony Polukhin, 4 years ago

Milestone: To Be DeterminedBoost 1.69
Resolution: fixed
Severity: OptimizationCosmetic
Status: newclosed

Last portion of fixes merged in 6cfa994a

Note: See TracTickets for help on using tickets.