Revert "Extend sign-compare warnings to gcc"

This reverts commit 34446653c7.

Reverted https://github.com/pytorch/pytorch/pull/75544 on behalf of https://github.com/janeyx99
This commit is contained in:
PyTorch MergeBot 2022-04-12 18:22:53 +00:00
parent 761bb06292
commit 80e05b7df4
3 changed files with 5 additions and 13 deletions

View File

@ -787,6 +787,7 @@ if(NOT MSVC)
string(APPEND CMAKE_CXX_FLAGS " -Wno-type-limits")
string(APPEND CMAKE_CXX_FLAGS " -Wno-array-bounds")
string(APPEND CMAKE_CXX_FLAGS " -Wno-unknown-pragmas")
string(APPEND CMAKE_CXX_FLAGS " -Wno-sign-compare")
string(APPEND CMAKE_CXX_FLAGS " -Wno-unused-parameter")
string(APPEND CMAKE_CXX_FLAGS " -Wno-unused-function")
string(APPEND CMAKE_CXX_FLAGS " -Wno-unused-result")
@ -797,6 +798,8 @@ if(NOT MSVC)
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
string(APPEND CMAKE_CXX_FLAGS " -Wno-range-loop-analysis")
string(APPEND CMAKE_CXX_FLAGS " -Wno-pass-failed")
# sign-compare is not part of -Wall, see https://godbolt.org/z/s1YczM41T
string(APPEND CMAKE_CXX_FLAGS " -Wsign-compare")
endif()
if(CMAKE_COMPILER_IS_GNUCXX AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0.0))
string(APPEND CMAKE_CXX_FLAGS " -Wno-stringop-overflow")

View File

@ -70,14 +70,6 @@ inline constexpr bool signs_differ(const T& a, const U& b) {
return is_negative(a) != is_negative(b);
}
// Suppress sign compare warning when compiling with GCC
// as later does not account for short-circuit rule before
// raising the warning, see https://godbolt.org/z/Tr3Msnz99
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-compare"
#endif
/// Returns true if x is greater than the greatest value of the type Limit
template <typename Limit, typename T>
inline constexpr bool greater_than_max(const T& x) {
@ -86,10 +78,6 @@ inline constexpr bool greater_than_max(const T& x) {
return can_overflow && x > std::numeric_limits<Limit>::max();
}
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
/// Returns true if x < lowest(Limit). Standard comparison
template <typename Limit, typename T>
static inline constexpr bool less_than_lowest(

View File

@ -301,7 +301,8 @@ int LoadBalancer::acquire() {
size_t minusers = SIZE_MAX;
int minIdx = 0;
for (size_t i = 0; i < n_; ++i, ++last) {
if (last >= static_cast<int>(n_)) {
// NOLINTNEXTLINE(clang-diagnostic-sign-compare)
if (last >= n_) {
last = 0;
}
uint64_t prev = 0;