Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-3777

clang 11.0.3 compile warnings in libbson

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: libbson
    • None

      Related to CDRIVER-3776. I see these compile warnings in libbson 1.17.0 with clang 11.0.3:

      python3.8 setup.py build_ext -i
      running build_ext
      building 'bsonjs' extension
      creating build
      creating build/temp.macosx-10.9-x86_64-3.8
      creating build/temp.macosx-10.9-x86_64-3.8/src
      creating build/temp.macosx-10.9-x86_64-3.8/src/bson
      creating build/temp.macosx-10.9-x86_64-3.8/src/common
      creating build/temp.macosx-10.9-x86_64-3.8/src/jsonsl
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DBSON_COMPILATION=1 -Isrc -Isrc/bson -Isrc/jsonsl -Isrc/common -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c src/bsonjs.c -o build/temp.macosx-10.9-x86_64-3.8/src/bsonjs.o
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DBSON_COMPILATION=1 -Isrc -Isrc/bson -Isrc/jsonsl -Isrc/common -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c src/bson/bson-context.c -o build/temp.macosx-10.9-x86_64-3.8/src/bson/bson-context.o
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DBSON_COMPILATION=1 -Isrc -Isrc/bson -Isrc/jsonsl -Isrc/common -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c src/bson/bson-oid.c -o build/temp.macosx-10.9-x86_64-3.8/src/bson/bson-oid.o
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DBSON_COMPILATION=1 -Isrc -Isrc/bson -Isrc/jsonsl -Isrc/common -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c src/bson/bson-error.c -o build/temp.macosx-10.9-x86_64-3.8/src/bson/bson-error.o
      src/bson/bson-error.c:113:8: warning: incompatible integer to pointer conversion assigning to 'char *' from 'int' [-Wint-conversion]
         ret = strerror_r (err_code, buf, buflen);
             ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      1 warning generated.
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DBSON_COMPILATION=1 -Isrc -Isrc/bson -Isrc/jsonsl -Isrc/common -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c src/bson/bson-atomic.c -o build/temp.macosx-10.9-x86_64-3.8/src/bson/bson-atomic.o
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DBSON_COMPILATION=1 -Isrc -Isrc/bson -Isrc/jsonsl -Isrc/common -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c src/bson/bson-string.c -o build/temp.macosx-10.9-x86_64-3.8/src/bson/bson-string.o
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DBSON_COMPILATION=1 -Isrc -Isrc/bson -Isrc/jsonsl -Isrc/common -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c src/bson/bson-keys.c -o build/temp.macosx-10.9-x86_64-3.8/src/bson/bson-keys.o
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DBSON_COMPILATION=1 -Isrc -Isrc/bson -Isrc/jsonsl -Isrc/common -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c src/bson/bson-iter.c -o build/temp.macosx-10.9-x86_64-3.8/src/bson/bson-iter.o
      src/bson/bson-iter.c:639:29: warning: comparison of integers of different signs: 'int' and 'uint32_t' (aka 'unsigned int') [-Wsign-compare]
               if (binary_len + 4 != l) {
                   ~~~~~~~~~~~~~~ ^  ~
      1 warning generated.
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DBSON_COMPILATION=1 -Isrc -Isrc/bson -Isrc/jsonsl -Isrc/common -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c src/bson/bson-iso8601.c -o build/temp.macosx-10.9-x86_64-3.8/src/bson/bson-iso8601.o
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DBSON_COMPILATION=1 -Isrc -Isrc/bson -Isrc/jsonsl -Isrc/common -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c src/bson/bson-md5.c -o build/temp.macosx-10.9-x86_64-3.8/src/bson/bson-md5.o
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DBSON_COMPILATION=1 -Isrc -Isrc/bson -Isrc/jsonsl -Isrc/common -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c src/bson/bson-memory.c -o build/temp.macosx-10.9-x86_64-3.8/src/bson/bson-memory.o
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DBSON_COMPILATION=1 -Isrc -Isrc/bson -Isrc/jsonsl -Isrc/common -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c src/bson/bson-writer.c -o build/temp.macosx-10.9-x86_64-3.8/src/bson/bson-writer.o
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DBSON_COMPILATION=1 -Isrc -Isrc/bson -Isrc/jsonsl -Isrc/common -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c src/bson/bson-value.c -o build/temp.macosx-10.9-x86_64-3.8/src/bson/bson-value.o
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DBSON_COMPILATION=1 -Isrc -Isrc/bson -Isrc/jsonsl -Isrc/common -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c src/bson/bson-json.c -o build/temp.macosx-10.9-x86_64-3.8/src/bson/bson-json.o
      src/bson/bson-json.c:2090:39: warning: comparison of integers of different signs: 'ssize_t' (aka 'long') and 'size_t' (aka 'unsigned long') [-Wsign-compare]
                  if (reader->json_text_pos < reader->json->pos) {
                      ~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~
      src/bson/bson-json.c:2091:24: warning: comparison of integers of different signs: 'unsigned long' and 'ssize_t' (aka 'long') [-Wsign-compare]
                     accum = BSON_MIN (reader->json->pos - reader->json_text_pos, r);
                             ^         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ~
      src/bson/bson-macros.h:123:30: note: expanded from macro 'BSON_MIN'
      #define BSON_MIN(a, b) (((a) < (b)) ? (a) : (b))
                                ~  ^  ~
      2 warnings generated.
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DBSON_COMPILATION=1 -Isrc -Isrc/bson -Isrc/jsonsl -Isrc/common -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c src/bson/bson.c -o build/temp.macosx-10.9-x86_64-3.8/src/bson/bson.o
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DBSON_COMPILATION=1 -Isrc -Isrc/bson -Isrc/jsonsl -Isrc/common -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c src/bson/bcon.c -o build/temp.macosx-10.9-x86_64-3.8/src/bson/bcon.o
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DBSON_COMPILATION=1 -Isrc -Isrc/bson -Isrc/jsonsl -Isrc/common -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c src/bson/bson-version-functions.c -o build/temp.macosx-10.9-x86_64-3.8/src/bson/bson-version-functions.o
      gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DBSON_COMPILATION=1 -Isrc -Isrc/bson -Isrc/jsonsl -Isrc/common -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c src/bson/bson-decimal128.c -o build/temp.macosx-10.9-x86_64-3.8/src/bson/bson-decimal128.o
      src/bson/bson-decimal128.c:285:20: warning: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'int32_t' (aka 'int') [-Wsign-compare]
                       i < radix_position && (str_out - str) < BSON_DECIMAL128_STRING;
                       ~ ^ ~~~~~~~~~~~~~~
      src/bson/bson-decimal128.c:626:17: warning: comparison of integers of different signs: 'int32_t' (aka 'int') and 'size_t' (aka 'unsigned long') [-Wsign-compare]
         if (exponent <= radix_position && radix_position - exponent > (1 << 14)) {
             ~~~~~~~~ ^  ~~~~~~~~~~~~~~
      2 warnings generated.
      

      Exact clang version:

      gcc --version
      Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
      Apple clang version 11.0.3 (clang-1103.0.32.62)
      Target: x86_64-apple-darwin19.5.0
      Thread model: posix
      InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: