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

issue building on ubuntu 20.04 with -Wsign-compare #307

Closed
cenit opened this issue Feb 18, 2021 · 2 comments
Closed

issue building on ubuntu 20.04 with -Wsign-compare #307

cenit opened this issue Feb 18, 2021 · 2 comments

Comments

@cenit
Copy link
Contributor

cenit commented Feb 18, 2021

If I try to build v0.162.0 tests, it fails with this error:

[3/106] /usr/bin/c++  -I/mnt/vcpkg/buildtrees/jsoncons/src/a2ab3dead7-a018935420.clean/include -I/mnt/vcpkg/buildtrees/jsoncons/src/a2ab3dead7-a018935420.clean/tests -I/mnt/vcpkg/buildtrees/jsoncons/src/a2ab3dead7-a018935420.clean/third_party -I/mnt/vcpkg/buildtrees/jsoncons/src/a2ab3dead7-a018935420.clean/third_party/catch -fPIC -g -Werror -Wall -Wextra -Wcast-align -Wcast-qual -Wimplicit-fallthrough -pedantic -MD -MT tests/CMakeFiles/unit_tests.dir/bson/src/bson_cursor_tests.cpp.o -MF tests/CMakeFiles/unit_tests.dir/bson/src/bson_cursor_tests.cpp.o.d -o tests/CMakeFiles/unit_tests.dir/bson/src/bson_cursor_tests.cpp.o -c /mnt/vcpkg/buildtrees/jsoncons/src/a2ab3dead7-a018935420.clean/tests/bson/src/bson_cursor_tests.cpp
FAILED: tests/CMakeFiles/unit_tests.dir/bson/src/bson_cursor_tests.cpp.o 
/usr/bin/c++  -I/mnt/vcpkg/buildtrees/jsoncons/src/a2ab3dead7-a018935420.clean/include -I/mnt/vcpkg/buildtrees/jsoncons/src/a2ab3dead7-a018935420.clean/tests -I/mnt/vcpkg/buildtrees/jsoncons/src/a2ab3dead7-a018935420.clean/third_party -I/mnt/vcpkg/buildtrees/jsoncons/src/a2ab3dead7-a018935420.clean/third_party/catch -fPIC -g -Werror -Wall -Wextra -Wcast-align -Wcast-qual -Wimplicit-fallthrough -pedantic -MD -MT tests/CMakeFiles/unit_tests.dir/bson/src/bson_cursor_tests.cpp.o -MF tests/CMakeFiles/unit_tests.dir/bson/src/bson_cursor_tests.cpp.o.d -o tests/CMakeFiles/unit_tests.dir/bson/src/bson_cursor_tests.cpp.o -c /mnt/vcpkg/buildtrees/jsoncons/src/a2ab3dead7-a018935420.clean/tests/bson/src/bson_cursor_tests.cpp
In file included from /mnt/vcpkg/buildtrees/jsoncons/src/a2ab3dead7-a018935420.clean/include/jsoncons_ext/bson/bson.hpp:17,
                 from /mnt/vcpkg/buildtrees/jsoncons/src/a2ab3dead7-a018935420.clean/tests/bson/src/bson_cursor_tests.cpp:10:
/mnt/vcpkg/buildtrees/jsoncons/src/a2ab3dead7-a018935420.clean/include/jsoncons_ext/bson/bson_encoder.hpp: In instantiation of ‘bool jsoncons::bson::basic_bson_encoder<Sink, Allocator>::visit_uint64(uint64_t, jsoncons::semantic_tag, const jsoncons::ser_context&, std::error_code&) [with Sink = jsoncons::bytes_sink<std::vector<unsigned char> >; Allocator = std::allocator<char>; uint64_t = long unsigned int]’:
/mnt/vcpkg/buildtrees/jsoncons/src/a2ab3dead7-a018935420.clean/include/jsoncons_ext/bson/bson_encoder.hpp:396:10:   required from here
/mnt/vcpkg/buildtrees/jsoncons/src/a2ab3dead7-a018935420.clean/include/jsoncons_ext/bson/bson_encoder.hpp:434:25: error: comparison of integer expressions of different signedness: ‘uint64_t’ {aka ‘long unsigned int’} and ‘int’ [-Werror=sign-compare]
  434 |                 if (val <= (std::numeric_limits<int32_t>::max)())
      |                     ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@danielaparker
Copy link
Owner

danielaparker commented Feb 18, 2021

It's a warning when building with -Wsign-compare. Fixed in 0.162.1. -Wsign-compare enabled for gcc test builds.

@danielaparker danielaparker changed the title issue building on ubuntu 20.04 issue building on ubuntu 20.04 with -Wsign-compare Feb 19, 2021
@geiseri
Copy link

geiseri commented Mar 12, 2021

I also see this in a few other places on 20.04:

FAILED: tests/CMakeFiles/unit_tests.dir/fuzz_regression/src/fuzz_regression_tests.cpp.o 
/usr/bin/c++  -I/sources/vcpkg/buildtrees/jsoncons/src/375ece763c-c0d03ac258.clean/include -I/sources/vcpkg/buildtrees/jsoncons/src/375ece763c-c0d03ac258.clean/tests -I/sources/vcpkg/buildtrees/jsoncons/src/375ece763c-c0d03ac258.clean/third_party -I/sources/vcpkg/buildtrees/jsoncons/src/375ece763c-c0d03ac258.clean/third_party/catch -fPIC -g -Werror -Wall -Wextra -Wcast-align -Wcast-qual -Wimplicit-fallthrough -Wsign-compare -pedantic -MD -MT tests/CMakeFiles/unit_tests.dir/fuzz_regression/src/fuzz_regression_tests.cpp.o -MF tests/CMakeFiles/unit_tests.dir/fuzz_regression/src/fuzz_regression_tests.cpp.o.d -o tests/CMakeFiles/unit_tests.dir/fuzz_regression/src/fuzz_regression_tests.cpp.o -c /sources/vcpkg/buildtrees/jsoncons/src/375ece763c-c0d03ac258.clean/tests/fuzz_regression/src/fuzz_regression_tests.cpp
In file included from /sources/vcpkg/buildtrees/jsoncons/src/375ece763c-c0d03ac258.clean/include/jsoncons_ext/ubjson/ubjson.hpp:17,
                 from /sources/vcpkg/buildtrees/jsoncons/src/375ece763c-c0d03ac258.clean/tests/fuzz_regression/src/fuzz_regression_tests.cpp:6:
/sources/vcpkg/buildtrees/jsoncons/src/375ece763c-c0d03ac258.clean/include/jsoncons_ext/ubjson/ubjson_encoder.hpp: In instantiation of ‘bool jsoncons::ubjson::basic_ubjson_encoder<Sink, Allocator>::visit_uint64(uint64_t, jsoncons::semantic_tag, const jsoncons::ser_context&, std::error_code&) [with Sink = jsoncons::bytes_sink<std::vector<unsigned char> >; Allocator = std::allocator<char>; uint64_t = long unsigned int]’:
/sources/vcpkg/buildtrees/jsoncons/src/375ece763c-c0d03ac258.clean/include/jsoncons_ext/ubjson/ubjson_encoder.hpp:426:10:   required from here
/sources/vcpkg/buildtrees/jsoncons/src/375ece763c-c0d03ac258.clean/include/jsoncons_ext/ubjson/ubjson_encoder.hpp:436:22: error: comparison of integer expressions of different signedness: ‘uint64_t’ {aka ‘long unsigned int’} and ‘short int’ [-Werror=sign-compare]
  436 |         else if (val <= (std::numeric_limits<int16_t>::max)())
      |                  ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/sources/vcpkg/buildtrees/jsoncons/src/375ece763c-c0d03ac258.clean/include/jsoncons_ext/ubjson/ubjson_encoder.hpp:441:22: error: comparison of integer expressions of different signedness: ‘uint64_t’ {aka ‘long unsigned int’} and ‘int’ [-Werror=sign-compare]
  441 |         else if (val <= (std::numeric_limits<int32_t>::max)())
      |                  ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /sources/vcpkg/buildtrees/jsoncons/src/375ece763c-c0d03ac258.clean/include/jsoncons_ext/msgpack/msgpack.hpp:17,
                 from /sources/vcpkg/buildtrees/jsoncons/src/375ece763c-c0d03ac258.clean/tests/fuzz_regression/src/fuzz_regression_tests.cpp:7:
/sources/vcpkg/buildtrees/jsoncons/src/375ece763c-c0d03ac258.clean/include/jsoncons_ext/msgpack/msgpack_encoder.hpp: In instantiation of ‘bool jsoncons::msgpack::basic_msgpack_encoder<Sink, Allocator>::visit_uint64(uint64_t, jsoncons::semantic_tag, const jsoncons::ser_context&, std::error_code&) [with Sink = jsoncons::bytes_sink<std::vector<unsigned char> >; Allocator = std::allocator<char>; uint64_t = long unsigned int]’:
/sources/vcpkg/buildtrees/jsoncons/src/375ece763c-c0d03ac258.clean/include/jsoncons_ext/msgpack/msgpack_encoder.hpp:620:14:   required from here
/sources/vcpkg/buildtrees/jsoncons/src/375ece763c-c0d03ac258.clean/include/jsoncons_ext/msgpack/msgpack_encoder.hpp:670:29: error: comparison of integer expressions of different signedness: ‘uint64_t’ {aka ‘long unsigned int’} and ‘signed char’ [-Werror=sign-compare]
  670 |                     if (val <= (std::numeric_limits<int8_t>::max)())
      |                         ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants