From e67f92c55cb97558f2311a5fd544b9325b4651d0 Mon Sep 17 00:00:00 2001 From: Olli Lupton Date: Fri, 5 Nov 2021 20:17:11 +0100 Subject: [PATCH] Cleanup warnings with nvhpc/21.9. (#2582) * Cleanup warnings with nvhpc/21.9. * Move __NVCOMPILER check. * Be more explicit. * Immediately executed lambda. * Fix shadowing warning. --- include/fmt/core.h | 3 ++- include/fmt/format.h | 13 ++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 8e8d2f1ce443..01cf34cf1d4f 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -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 diff --git a/include/fmt/format.h b/include/fmt/format.h index c4c9321dc95c..f9d9f683ef2c 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -970,11 +970,14 @@ FMT_CONSTEXPR auto count_digits(UInt n) -> int { if (num_bits() == 32) return (FMT_BUILTIN_CLZ(static_cast(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;