Skip to content

Commit

Permalink
Cleanup warnings with nvhpc/21.9. (#2582)
Browse files Browse the repository at this point in the history
* Cleanup warnings with nvhpc/21.9.

* Move __NVCOMPILER check.

* Be more explicit.

* Immediately executed lambda.

* Fix shadowing warning.
  • Loading branch information
olupton authored Nov 5, 2021
1 parent 812733c commit e67f92c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
# define FMT_CLANG_VERSION 0
#endif

#if defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER)
#if defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER) && \
!defined(__NVCOMPILER)
# define FMT_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
#else
# define FMT_GCC_VERSION 0
Expand Down
13 changes: 8 additions & 5 deletions include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -970,11 +970,14 @@ FMT_CONSTEXPR auto count_digits(UInt n) -> int {
if (num_bits<UInt>() == 32)
return (FMT_BUILTIN_CLZ(static_cast<uint32_t>(n) | 1) ^ 31) / BITS + 1;
#endif
int num_digits = 0;
do {
++num_digits;
} while ((n >>= BITS) != 0);
return num_digits;
// Lambda avoids unreachable code warnings from NVHPC.
return [](UInt m) {
int num_digits = 0;
do {
++num_digits;
} while ((m >>= BITS) != 0);
return num_digits;
}(n);
}

template <> auto count_digits<4>(detail::fallback_uintptr n) -> int;
Expand Down

0 comments on commit e67f92c

Please sign in to comment.