For a while, GCC has generated warnings about sign errors. A common
mistake if compiling with clang was to accidentally introduce signedness
errors, which were picked up by the GCC builds.
This occurs due to an inconsistency in -Wall implementation between clang
and gcc: gcc includes sign-compare, clang does not.
See:
https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wall
vs
https://clang.llvm.org/docs/DiagnosticsReference.html#wall
Note that sign-compare is included under -Wextra for clang:
https://clang.llvm.org/docs/DiagnosticsReference.html#wextra
Clang will now generate similar warnings with -Wsign-compare:
https://clang.llvm.org/docs/DiagnosticsReference.html#wsign-compare
Interestingly, if specified on its own, -Wsign-compare will include
C, whereas gcc -Wall affects C++ only. Therefore we must work around
this in the make file to emulate the GCC behaviour in clang builds.
Also fix a couple of warnings found in some tests.
Signed-off-by: Alex Ainscow <aainscow@uk.ibm.com>
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-ignored-qualifiers>)
endif()
+if (CMAKE_CXX_COMPILER_ID STREQUAL Clang)
+ add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wsign-compare>)
+endif()
+
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-ftemplate-depth-1024>)
# Because Boost can't be bothered to not include its own deprecated headers
// for each missing shard.
for (auto a : available) {
minimum_set.insert(a);
- if (minimum_set.size() == data_chunk_count) {
+ if (std::cmp_equal(minimum_set.size(), data_chunk_count)) {
break;
}
}
- if (minimum_set.size() != data_chunk_count) {
+ if (std::cmp_not_equal(minimum_set.size(), data_chunk_count)) {
minimum_set.clear();
return -EIO; // Cannot recover.
}
}
return 0;
}
-
[[deprecated]]
int minimum_to_decode(const std::set<int> &want_to_read,
const std::set<int> &available,
}
for (shard_id_t i; i < get_ec_sinfo().get_k(); ++i) {
- for (int j = 0; j < get_ec_sinfo().get_chunk_size(); j++) {
+ for (int j = 0; std::cmp_less(j, get_ec_sinfo().get_chunk_size()); j++) {
encode_map.at(i).c_str()[j] =
chunks[j + (get_ec_sinfo().get_chunk_size() * i.id)];
for (shard_id_t k{static_cast<int8_t>(get_ec_sinfo().get_k_plus_m())};