File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,12 @@ GSL_SUPPRESS(f.6) // NO-FORMAT: attribute // TODO: MSVC /analyze does not recogn
3636 constexpr const bool is_different_signedness =
3737 (std::is_signed<T>::value != std::is_signed<U>::value);
3838
39- const T t = narrow_cast<T>(u);
39+ GSL_SUPPRESS(es.103) // NO-FORMAT: attribute // don't overflow
40+ GSL_SUPPRESS(es.104) // NO-FORMAT: attribute // don't underflow
41+ GSL_SUPPRESS(p.2) // NO-FORMAT: attribute // don't rely on undefined behavior
42+ const T t = narrow_cast<T>(u); // While this is technically undefined behavior in some cases (i.e., if the source value is of floating-point type
43+ // and cannot fit into the destination integral type), the resultant behavior is benign on the platforms
44+ // that we target (i.e., no hardware trap representations are hit).
4045
4146 if (static_cast<U>(t) != u || (is_different_signedness && ((t < T{}) != (u < U{}))))
4247 {
You can’t perform that action at this time.
0 commit comments