Skip to content

Commit

Permalink
Suppress es.46 warning in implementation of gsl::narrow (#1046)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dmitrykobets-msft committed Apr 28, 2022
1 parent 7fefaaf commit d8c493c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/gsl/narrow
Expand Up @@ -31,6 +31,10 @@ template <class T, class U, typename std::enable_if<std::is_arithmetic<T>::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)
{
Expand Down

0 comments on commit d8c493c

Please sign in to comment.