[MONGOCRYPT-501] libmongocrypt fails to compile on Ubuntu 18.04 with Clang 7.0.1 Created: 28/Nov/22  Updated: 28/Oct/23  Resolved: 01/Dec/22

Status: Closed
Project: Libmongocrypt
Component/s: None
Affects Version/s: None
Fix Version/s: 1.7.0, 1.7.0-alpha1

Type: Bug Priority: Major - P3
Reporter: Mark Benvenuto Assignee: Kevin Albertson
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Binding Changes: Not Needed

 Description   

Problem:
/src/mc-range-encoding.c fails to compile with clang 7.0.1 on Ubuntu 18.04 with -Werror ernabled. This is the build environment for MongoDB 6.0 sanitizer builds. Eror does not occur with Gcc.

Repro:
cmake -DCMAKE_C_FLAGS="-Werror" -DCMAKE_C_COMPILER=/opt/mongodbtoolchain/v3/bin/clang -DCMAKE_CXX_COMPILER=/opt/mongodbtoolchain/v3/bin/clang++ -GNinja

Errors:

[16/394] Building C object CMakeFiles/mongocrypt.dir/src/mc-range-encoding.c.o
FAILED: CMakeFiles/mongocrypt.dir/src/mc-range-encoding.c.o
/opt/mongodbtoolchain/v3/bin/clang -DBSON_STATIC -DKMS_MSG_STATIC -DMLIB_HAVE_STRINGS_H -DMLIB_USER -DMONGOCRYPT_LITTLE_ENDIAN -Dmongocrypt_EXPORTS -I/home/ubuntu/src/libmongocrypt/kms-message/src -I/home/ubuntu/src/libmongocrypt/src -I/home/ubuntu/src/libmongocrypt/repro/src -I/home/ubuntu/src/libmongocrypt/repro/_deps/embedded_mcd-src/src/libbson/src -I/home/ubuntu/src/libmongocrypt/repro/_mongo-c-driver/src/libbson/src -I/home/ubuntu/src/libmongocrypt/repro/_mongo-c-driver/src/libbson/src/bson -fPIC -Werror=implicit -Werror=return-type -Werror=incompatible-pointer-types -Werror=int-conversion -Werror=ignored-qualifiers -Werror=uninitialized -fPIC -pthread -std=gnu99 -MD -MT CMakeFiles/mongocrypt.dir/src/mc-range-encoding.c.o -MF CMakeFiles/mongocrypt.dir/src/mc-range-encoding.c.o.d -o CMakeFiles/mongocrypt.dir/src/mc-range-encoding.c.o -c /home/ubuntu/src/libmongocrypt/src/mc-range-encoding.c
/home/ubuntu/src/libmongocrypt/src/mc-range-encoding.c:193:20: error: implicit conversion loses floating-point precision: 'double' to 'float' [-Werror,-Wconversion]
   if (isinf (args.value) || isnan (args.value)) {
       ~~~~~~~~~~~~^~~~~~
/usr/include/math.h:661:46: note: expanded from macro 'isinf'
#  define isinf(x) __MATH_TG ((x), __isinf, (x))
                   ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/math.h:559:16: note: expanded from macro '__MATH_TG'
   ? FUNC ## f ARGS                             \
     ~~~~~~~~~ ^~~~
/home/ubuntu/src/libmongocrypt/src/mc-range-encoding.c:193:42: error: implicit conversion loses floating-point precision: 'double' to 'float' [-Werror,-Wconversion]
   if (isinf (args.value) || isnan (args.value)) {
                             ~~~~~~~~~~~~^~~~~~
/usr/include/math.h:644:46: note: expanded from macro 'isnan'
#  define isnan(x) __MATH_TG ((x), __isnan, (x))
                   ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/math.h:559:16: note: expanded from macro '__MATH_TG'
   ? FUNC ## f ARGS                             \
     ~~~~~~~~~ ^~~~
/home/ubuntu/src/libmongocrypt/src/mc-range-encoding.c:247:21: error: implicit conversion loses floating-point precision: 'double' to 'float' [-Werror,-Wconversion]
      if (isfinite (range)) {
          ~~~~~~~~~~^~~~~~
/usr/include/math.h:629:50: note: expanded from macro 'isfinite'
#  define isfinite(x) __MATH_TG ((x), __finite, (x))
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/math.h:559:16: note: expanded from macro '__MATH_TG'
   ? FUNC ## f ARGS                             \
     ~~~~~~~~~ ^~~~
/home/ubuntu/src/libmongocrypt/src/mc-range-encoding.c:254:24: error: implicit conversion loses floating-point precision: 'double' to 'float' [-Werror,-Wconversion]
         if (isfinite (rangeAndPrecision)) {
             ~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/math.h:629:50: note: expanded from macro 'isfinite'
#  define isfinite(x) __MATH_TG ((x), __finite, (x))
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/math.h:559:16: note: expanded from macro '__MATH_TG'
   ? FUNC ## f ARGS                             \
     ~~~~~~~~~ ^~~~
4 errors generated.



 Comments   
Comment by Githook User [ 30/Nov/22 ]

Author:

{'name': 'Kevin Albertson', 'email': 'kevin.albertson@mongodb.com', 'username': 'kevinAlbs'}

Message: MONGOCRYPT-501 fix expected error message
Branch: master
https://github.com/mongodb/libmongocrypt/commit/c1dbee1112221568c8568d1804624fa5d69a2d4e

Comment by Githook User [ 30/Nov/22 ]

Author:

{'name': 'Kevin Albertson', 'email': 'kevin.albertson@mongodb.com', 'username': 'kevinAlbs'}

Message: MONGOCRYPT-501 fix conversion warning on clang 7 with glibc (#507)

  • add Ubuntu 18.04 64-bit clang7 variant
  • add mc_isnan, ms_isinf, mc_isfinite

This is useful for ignoring conversion error on isinf, isnan, and isfinite

  • Update src/mc-range-encoding.c

Co-authored-by: Roberto C. Sánchez <roberto@connexer.com>
Branch: master
https://github.com/mongodb/libmongocrypt/commit/9a36079115b309f1b18394d17be1413e891cea4f

Generated at Thu Feb 08 09:08:49 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.