From d8c493c89fef3b1928803cf0af5a21630344ea7e Mon Sep 17 00:00:00 2001 From: dmitrykobets-msft <89153909+dmitrykobets-msft@users.noreply.github.com> Date: Thu, 28 Apr 2022 09:49:38 -0700 Subject: [PATCH] Suppress es.46 warning in implementation of gsl::narrow (#1046) As per the CoreGuidelines, gsl::narrow is defined in terms of static_cast. Suppress es.46, which suggests converting the static_cast into gsl::narrow --- include/gsl/narrow | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/gsl/narrow b/include/gsl/narrow index 32d271e..7578c8b 100644 --- a/include/gsl/narrow +++ b/include/gsl/narrow @@ -31,6 +31,10 @@ template ::value // clang-format off GSL_SUPPRESS(type.1) // NO-FORMAT: attribute GSL_SUPPRESS(f.6) // NO-FORMAT: attribute // TODO: MSVC /analyze does not recognise noexcept(false) +GSL_SUPPRESS(es.46) // NO-FORMAT: attribute // The warning suggests that a floating->unsigned conversion can occur + // in the static_cast below, and that gsl::narrow should be used instead. + // Suppress this warning, since gsl::narrow is defined in terms of + // static_cast // clang-format on constexpr T narrow(U u) noexcept(false) {