eclipse-uprotocol / up-cpp

uProtocol Language Specific Library for C++
Apache License 2.0
18 stars 25 forks source link

Add clang-13 to the CI build #300

Open gregmedd opened 2 months ago

gregmedd commented 2 months ago

Clang has different checks and can be more pedantic than gcc. We should be including clang-13 in our CI process to make sure we actually support the versions we claim in our documentation.

gregmedd commented 2 months ago

Just as a quick check, I tried compiling up-cpp with clang++-18 and got several errors:

/home/user/.conan2/p/b/up-cp85320fffd98f5/b/src/datamodel/serializer/Uuid.cpp:109:20: error: implicit conversion changes signedness: 'int' to 'uint64_t' (aka 'unsigned long') [-Werror,-Wsign-conversion]
  108 |         uuid.set_msb((unix_ts_ms << UUID_TIMESTAMP_SHIFT) |
      |                                                           ~
  109 |                      (ver << UUID_VERSION_SHIFT) | rand_a);
      |                       ~~~~^~~~~~~~~~~~~~~~~~~~~
1 error generated.
gmake[2]: *** [CMakeFiles/up-cpp.dir/build.make:216: CMakeFiles/up-cpp.dir/src/datamodel/serializer/Uuid.cpp.o] Error 1
gmake[2]: *** Waiting for unfinished jobs....
/home/user/.conan2/p/b/up-cp85320fffd98f5/b/src/communication/RpcClient.cpp:135:18: error: captured structured bindings are a C++20 extension [-Werror,-Wc++20-extensions]
  135 |         auto wrapper = [callable, reqid = std::move(reqid),
      |                         ^
/home/user/.conan2/p/b/up-cp85320fffd98f5/b/src/communication/RpcClient.cpp:127:25: note: 'callable' declared here
  127 |         auto [callback_handle, callable] =
      |                                ^
/home/user/.conan2/p/b/up-cp85320fffd98f5/b/src/communication/RpcClient.cpp:140:38: error: captured structured bindings are a C++20 extension [-Werror,-Wc++20-extensions]
  140 |                                 std::call_once(*callback_once, [&callable, &m]() {
      |                                                                  ^
/home/user/.conan2/p/b/up-cp85320fffd98f5/b/src/communication/RpcClient.cpp:127:25: note: 'callable' declared here
  127 |         auto [callback_handle, callable] =
      |                                ^
/home/user/.conan2/p/b/up-cp85320fffd98f5/b/src/communication/RpcClient.cpp:148:38: error: captured structured bindings are a C++20 extension [-Werror,-Wc++20-extensions]
  148 |                                 std::call_once(*callback_once, [&callable,
      |                                                                  ^
/home/user/.conan2/p/b/up-cp85320fffd98f5/b/src/communication/RpcClient.cpp:127:25: note: 'callable' declared here
  127 |         auto [callback_handle, callable] =
      |                                ^
/home/user/.conan2/p/b/up-cp85320fffd98f5/b/src/communication/RpcClient.cpp:160:17: error: captured structured bindings are a C++20 extension [-Werror,-Wc++20-extensions]
  160 |         auto expire = [callable, callback_once](v1::UStatus&& reason) mutable {
      |                        ^
/home/user/.conan2/p/b/up-cp85320fffd98f5/b/src/communication/RpcClient.cpp:127:25: note: 'callable' declared here
  127 |         auto [callback_handle, callable] =
      |                                ^
/home/user/.conan2/p/b/up-cp85320fffd98f5/b/src/communication/RpcClient.cpp:162:25: error: captured structured bindings are a C++20 extension [-Werror,-Wc++20-extensions]
  162 |                     *callback_once, [&callable, reason = std::move(reason)]() {
      |                                       ^
/home/user/.conan2/p/b/up-cp85320fffd98f5/b/src/communication/RpcClient.cpp:127:25: note: 'callable' declared here
  127 |         auto [callback_handle, callable] =
      |                                ^
5 errors generated.
gmake[2]: *** [CMakeFiles/up-cpp.dir/build.make:118: CMakeFiles/up-cpp.dir/src/communication/RpcClient.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:140: CMakeFiles/up-cpp.dir/all] Error 2
gmake: *** [Makefile:146: all] Error 2

It is possible that some of our strange false-positives with clang-tidy (#298) trace back to unreported clang compilation errors.