Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: Add -Wsign-conversion to CXXFLAGS
-Wsign-conversion is by default enabled in Clang with -Wconversion, but disabled in GCC. Unintented type coercion can misinterpret the sign as in: libdnf5-cli/output/transaction_table.cpp:181:97: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion] 181 | P_(" Skipping: {:4} package\n", " Skipping: {:4} packages\n", skips), skips) | ^~~~~ This would be missed when compiling with GCC, but causing a build failure with Clang. This patch brings GCC and Clang compilers in line, both to enable -Wsign-conversion. However, it disables the warning for SWIG-generated bindings as the generated code violates the warning many times, like here for Perl: bindings/perl5/libdnf5/CMakeFiles/perl5_advisory.dir/advisoryPERL_wrap.cxx:700:36: error: conversion to ‘long unsigned int’ from ‘long int’ may change the sign of the result [-Werror=sign-conversion] 700 | if (strlen(name) + 1 > (bsz - (r - buff))) return 0; | ~~~^~~~~~~ Related: rpm-software-management#1701
- Loading branch information