Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build warnings (-Wsign-conversion) under Clang #4

Closed
rotu opened this issue Mar 17, 2020 · 9 comments · Fixed by #7
Closed

Build warnings (-Wsign-conversion) under Clang #4

rotu opened this issue Mar 17, 2020 · 9 comments · Fixed by #7
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@rotu
Copy link

rotu commented Mar 17, 2020

MacOS Catalina 10.15.4 Beta
Apple clang version 11.0.0 (clang-1100.0.33.17)

--- stderr: spdlog_vendor                                                                                                
In file included from /opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/src/fmt.cpp:10:
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/include/spdlog/fmt/bundled/format-inl.h:484:48: warning: implicit conversion changes signedness: 'int' to 'unsigned long long' [-Wsign-conversion]
          (min_exponent + fp::significand_size - 1) * one_over_log2_10 +
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~  ~
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/include/spdlog/fmt/bundled/format-inl.h:534:53: warning: implicit conversion changes signedness: 'int' to 'std::size_t' (aka 'unsigned long') [-Wsign-conversion]
    auto result = static_cast<double_bigit>(bigits_[index]) - other - borrow;
                                            ~~~~~~~ ^~~~~
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/include/spdlog/fmt/bundled/format-inl.h:535:13: warning: implicit conversion changes signedness: 'int' to 'std::size_t' (aka 'unsigned long') [-Wsign-conversion]
    bigits_[index] = static_cast<bigit>(result);
    ~~~~~~~ ^~~~~
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/include/spdlog/fmt/bundled/format-inl.h:541:38: warning: implicit conversion changes signedness: 'int' to 'std::size_t' (aka 'unsigned long') [-Wsign-conversion]
    while (num_bigits > 0 && bigits_[num_bigits] == 0) --num_bigits;
                             ~~~~~~~ ^~~~~~~~~~
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/include/spdlog/fmt/bundled/format-inl.h:542:31: warning: implicit conversion changes signedness: 'int' to 'std::size_t' (aka 'unsigned long') [-Wsign-conversion]
    bigits_.resize(num_bigits + 1);
            ~~~~~~ ~~~~~~~~~~~^~~
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/include/spdlog/fmt/bundled/format-inl.h:553:40: warning: implicit conversion changes signedness: 'int' to 'std::size_t' (aka 'unsigned long') [-Wsign-conversion]
      subtract_bigits(i, other.bigits_[j], borrow);
                         ~~~~~         ^
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/include/spdlog/fmt/bundled/format-inl.h:605:25: warning: implicit conversion changes signedness: 'int' to 'std::size_t' (aka 'unsigned long') [-Wsign-conversion]
      bigits_[num_bigits++] = n & ~bigit(0);
      ~~~~~~~ ~~~~~~~~~~^~
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/include/spdlog/fmt/bundled/format-inl.h:608:20: warning: implicit conversion changes signedness: 'int' to 'std::size_t' (aka 'unsigned long') [-Wsign-conversion]
    bigits_.resize(num_bigits);
            ~~~~~~ ^~~~~~~~~~
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/include/spdlog/fmt/bundled/format-inl.h:644:37: warning: implicit conversion changes signedness: 'int' to 'std::size_t' (aka 'unsigned long') [-Wsign-conversion]
      bigit lhs_bigit = lhs.bigits_[i], rhs_bigit = rhs.bigits_[j];
                        ~~~         ^
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/include/spdlog/fmt/bundled/format-inl.h:644:65: warning: implicit conversion changes signedness: 'int' to 'std::size_t' (aka 'unsigned long') [-Wsign-conversion]
      bigit lhs_bigit = lhs.bigits_[i], rhs_bigit = rhs.bigits_[j];
                                                    ~~~         ^
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/include/spdlog/fmt/bundled/format-inl.h:659:62: warning: implicit conversion changes signedness: 'int' to 'std::size_t' (aka 'unsigned long') [-Wsign-conversion]
      return i >= n.exp_ && i < n.num_bigits() ? n.bigits_[i - n.exp_] : 0;
                                                 ~         ~~^~~~~~~~
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/include/spdlog/fmt/bundled/format-inl.h:699:20: warning: implicit conversion changes signedness: 'int' to 'std::size_t' (aka 'unsigned long') [-Wsign-conversion]
    bigits_.resize(num_result_bigits);
            ~~~~~~ ^~~~~~~~~~~~~~~~~
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/include/spdlog/fmt/bundled/format-inl.h:707:44: warning: implicit conversion changes signedness: 'int' to 'std::size_t' (aka 'unsigned long') [-Wsign-conversion]
        sum += static_cast<double_bigit>(n[i]) * n[j];
                                         ~ ^
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/include/spdlog/fmt/bundled/format-inl.h:707:52: warning: implicit conversion changes signedness: 'int' to 'std::size_t' (aka 'unsigned long') [-Wsign-conversion]
        sum += static_cast<double_bigit>(n[i]) * n[j];
                                                 ~ ^
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/include/spdlog/fmt/bundled/format-inl.h:709:15: warning: implicit conversion changes signedness: 'int' to 'std::size_t' (aka 'unsigned long') [-Wsign-conversion]
      bigits_[bigit_index] = static_cast<bigit>(sum);
      ~~~~~~~ ^~~~~~~~~~~
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/include/spdlog/fmt/bundled/format-inl.h:716:45: warning: implicit conversion changes signedness: 'int' to 'std::size_t' (aka 'unsigned long') [-Wsign-conversion]
        sum += static_cast<double_bigit>(n[i++]) * n[j--];
                                         ~ ~^~
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/include/spdlog/fmt/bundled/format-inl.h:716:55: warning: implicit conversion changes signedness: 'int' to 'std::size_t' (aka 'unsigned long') [-Wsign-conversion]
        sum += static_cast<double_bigit>(n[i++]) * n[j--];
                                                   ~ ~^~
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/include/spdlog/fmt/bundled/format-inl.h:717:15: warning: implicit conversion changes signedness: 'int' to 'std::size_t' (aka 'unsigned long') [-Wsign-conversion]
      bigits_[bigit_index] = static_cast<bigit>(sum);
      ~~~~~~~ ^~~~~~~~~~~
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/include/spdlog/fmt/bundled/format-inl.h:735:33: warning: implicit conversion changes signedness: 'int' to 'std::size_t' (aka 'unsigned long') [-Wsign-conversion]
      bigits_.resize(num_bigits + exp_difference);
              ~~~~~~ ~~~~~~~~~~~^~~~~~~~~~~~~~~~
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/include/spdlog/fmt/bundled/format-inl.h:737:17: warning: implicit conversion changes signedness: 'int' to 'std::size_t' (aka 'unsigned long') [-Wsign-conversion]
        bigits_[j] = bigits_[i];
        ~~~~~~~ ^
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/include/spdlog/fmt/bundled/format-inl.h:737:30: warning: implicit conversion changes signedness: 'int' to 'std::size_t' (aka 'unsigned long') [-Wsign-conversion]
        bigits_[j] = bigits_[i];
                     ~~~~~~~ ^
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/include/spdlog/fmt/bundled/format-inl.h:1031:18: warning: implicit conversion changes signedness: 'int' to 'std::size_t' (aka 'unsigned long') [-Wsign-conversion]
      buf.resize(num_digits);
          ~~~~~~ ^~~~~~~~~~
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/include/spdlog/fmt/bundled/format-inl.h:1077:47: warning: implicit conversion changes signedness: 'int' to 'std::size_t' (aka 'unsigned long') [-Wsign-conversion]
      while (num_digits > 0 && buf[num_digits - 1] == '0') {
                               ~~~ ~~~~~~~~~~~^~~
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/include/spdlog/fmt/bundled/format-inl.h:1182:30: warning: implicit conversion changes signedness: 'int' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
      std::memmove(p, p + 1, fraction_size);
      ~~~                    ^~~~~~~~~~~~~
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/include/spdlog/fmt/bundled/format-inl.h:1211:42: warning: implicit conversion changes signedness: 'int' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
      std::memmove(begin + 1, begin + 2, fraction_size);
      ~~~                                ^~~~~~~~~~~~~
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/include/spdlog/fmt/bundled/format-inl.h:1213:16: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
    buf.resize(fraction_size + offset + 1);
               ^~~~~~~~~~~~~ ~
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/include/spdlog/fmt/bundled/format-inl.h:1182:30: warning: implicit conversion changes signedness: 'int' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
      std::memmove(p, p + 1, fraction_size);
      ~~~                    ^~~~~~~~~~~~~
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/src/fmt.cpp:156:40: note: in instantiation of function template specialization 'fmt::v6::internal::snprintf_float<double>' requested here
        template FMT_API int internal::snprintf_float(double, int,
                                       ^
In file included from /opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/src/fmt.cpp:10:
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/include/spdlog/fmt/bundled/format-inl.h:1211:42: warning: implicit conversion changes signedness: 'int' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
      std::memmove(begin + 1, begin + 2, fraction_size);
      ~~~                                ^~~~~~~~~~~~~
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/include/spdlog/fmt/bundled/format-inl.h:1213:16: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
    buf.resize(fraction_size + offset + 1);
               ^~~~~~~~~~~~~ ~
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/include/spdlog/fmt/bundled/format-inl.h:1182:30: warning: implicit conversion changes signedness: 'int' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
      std::memmove(p, p + 1, fraction_size);
      ~~~                    ^~~~~~~~~~~~~
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/src/fmt.cpp:159:40: note: in instantiation of function template specialization 'fmt::v6::internal::snprintf_float<long double>' requested here
        template FMT_API int internal::snprintf_float(long double, int,
                                       ^
In file included from /opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/src/fmt.cpp:10:
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/include/spdlog/fmt/bundled/format-inl.h:1211:42: warning: implicit conversion changes signedness: 'int' to 'size_t' (aka 'unsigned long') [-Wsign-conversion]
      std::memmove(begin + 1, begin + 2, fraction_size);
      ~~~                                ^~~~~~~~~~~~~
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/include/spdlog/fmt/bundled/format-inl.h:1213:16: warning: implicit conversion changes signedness: 'int' to 'unsigned long' [-Wsign-conversion]
    buf.resize(fraction_size + offset + 1);
               ^~~~~~~~~~~~~ ~
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/include/spdlog/fmt/bundled/format-inl.h:1077:47: warning: implicit conversion changes signedness: 'int' to 'std::size_t' (aka 'unsigned long') [-Wsign-conversion]
      while (num_digits > 0 && buf[num_digits - 1] == '0') {
                               ~~~ ~~~~~~~~~~~^~~
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/src/fmt.cpp:162:40: note: in instantiation of function template specialization 'fmt::v6::internal::format_float<double>' requested here
        template FMT_API int internal::format_float(double, int, internal::float_specs,
                                       ^
In file included from /opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/src/fmt.cpp:10:
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/include/spdlog/fmt/bundled/format-inl.h:1077:47: warning: implicit conversion changes signedness: 'int' to 'std::size_t' (aka 'unsigned long') [-Wsign-conversion]
      while (num_digits > 0 && buf[num_digits - 1] == '0') {
                               ~~~ ~~~~~~~~~~~^~~
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/src/fmt.cpp:164:40: note: in instantiation of function template specialization 'fmt::v6::internal::format_float<long double>' requested here
        template FMT_API int internal::format_float(long double, int,
                                       ^
In file included from /opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/src/fmt.cpp:10:
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/include/spdlog/fmt/bundled/format-inl.h:1031:18: warning: implicit conversion changes signedness: 'int' to 'std::size_t' (aka 'unsigned long') [-Wsign-conversion]
      buf.resize(num_digits);
          ~~~~~~ ^~~~~~~~~~
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/include/spdlog/fmt/bundled/format-inl.h:1108:7: note: in instantiation of function template specialization 'fmt::v6::internal::fallback_format<double>' requested here
      fallback_format(value, buf, exp);
      ^
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/include/spdlog/fmt/bundled/format-inl.h:1031:18: warning: implicit conversion changes signedness: 'int' to 'std::size_t' (aka 'unsigned long') [-Wsign-conversion]
      buf.resize(num_digits);
          ~~~~~~ ^~~~~~~~~~
/opt/ros/master/build/spdlog_vendor/spdlog-1.5.0-prefix/src/spdlog-1.5.0/include/spdlog/fmt/bundled/format-inl.h:1108:7: note: in instantiation of function template specialization 'fmt::v6::internal::fallback_format<long double>' requested here
      fallback_format(value, buf, exp);
      ^
36 warnings generated.
---
Finished <<< spdlog_vendor [6min 45s]
@clalancette
Copy link
Contributor

That does look like a problem. But for what its worth, we shouldn't be building at all on macOS. Instead you should be getting spdlog from brew. This PR added instructions for macOS.

@rotu
Copy link
Author

rotu commented Mar 17, 2020

@clalancette I was building from ros2.repos so maybe spdlog_vendor should be removed from that file?

@dirk-thomas dirk-thomas added the question Further information is requested label Mar 18, 2020
@dirk-thomas
Copy link
Member

maybe spdlog_vendor should be removed from that file?

No, the vendor packages are intentionally part of the workspace on all platforms. They choose between which version of the vendor package is used. Sometimes they even provide CMake modules to find a vendor package which doesn't provide it out-of-the-box.

As @clalancette mentioned you need to follow the install instructions and install the dependency. Assuming that resolves the question I will go ahead and close this.

@rotu
Copy link
Author

rotu commented Mar 18, 2020

@dirk-thomas @clalancette That doesn't resolve the issue, and I don't know why you think it would. Please reopen this ticket; there are code quality issues here that need investigation. These mistakes should be reviewed and either fixed or suppressed as appropriate.

@dirk-thomas
Copy link
Member

Please post the compiler warnings you are seeing after having installed the dependency as described in the instructions and I will reopen the ticket.

@rotu
Copy link
Author

rotu commented Mar 18, 2020

@dirk-thomas I think we're on different pages. You're telling me not to build a package and then look at that package for build warnings in the source code that I did not build?

Well anyway, here are the build warnings in Linux CI with Clang. They are exactly the same as I originally reported:

https://ci.ros2.org/view/All/job/nightly_linux_clang_libcxx/354/clang/#issuesContent

@rotu rotu changed the title Lots of build warnings on Mac + Clang Build warnings (-Wsign-conversion) under Clang Mar 18, 2020
@clalancette
Copy link
Contributor

I totally agree that there are warnings here, and they should be looked at. In all likelihood, these will need to be fixed upstream in spdlog (actually upstream in fmt, which spdlog vendors).

That being said, this is going to be low priority for us. The reason for that is that on our default platforms for Foxy (Ubuntu Focal, macOS Mojave, and Windows 10), we don't see these issues. Why? Because on Ubuntu and macOS, spdlog_vendor correctly finds the system package, so we don't build anything (and hence don't see the warnings). We do build on Windows 10, but since it isn't clang we don't see the warnings there either.

The reason you saw the issues again when you ran the nightly_linux_clang job is that that job is still configured to use Ubuntu Bionic, which doesn't have the up-to-date spdlog system package. And thus it falls back to building again.

So I am going to reopen, as it is a bug, but I'm not sure whether we'll have time to address it before Foxy. If you'd like to contribute a patch to spdlog/fmt to fix those, that would be great; we could then update our vendored spdlog appropriately.

@clalancette clalancette reopened this Mar 18, 2020
@clalancette clalancette added bug Something isn't working help wanted Extra attention is needed and removed question Further information is requested labels Mar 18, 2020
@dirk-thomas
Copy link
Member

these will need to be fixed upstream in spdlog (actually upstream in fmt, which spdlog vendors).

That being said, this is going to be low priority for us. The reason for that is that on our default platforms for Foxy

@rotu Please create a ticket upstream about this and post a reference here. After that I propose we close this ticket as a duplicate.

@Karsten1987
Copy link
Contributor

Karsten1987 commented Mar 24, 2020

I opened a ticket upstream: gabime/spdlog#1488 fmtlib/fmt#1604

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants