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
This commit is contained in:
dmitrykobets-msft 2022-04-28 09:49:38 -07:00 committed by GitHub
parent 7fefaaf2c8
commit d8c493c89f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,6 +31,10 @@ template <class T, class U, typename std::enable_if<std::is_arithmetic<T>::value
// clang-format off // clang-format off
GSL_SUPPRESS(type.1) // NO-FORMAT: attribute GSL_SUPPRESS(type.1) // NO-FORMAT: attribute
GSL_SUPPRESS(f.6) // NO-FORMAT: attribute // TODO: MSVC /analyze does not recognise noexcept(false) 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 // clang-format on
constexpr T narrow(U u) noexcept(false) constexpr T narrow(U u) noexcept(false)
{ {