diff --git a/folly/Conv.cpp b/folly/Conv.cpp index b953dd8c607..0ec8e5372d5 100644 --- a/folly/Conv.cpp +++ b/folly/Conv.cpp @@ -18,6 +18,8 @@ #include +#include + namespace folly { namespace detail { @@ -767,8 +769,9 @@ ConversionError makeConversionError(ConversionCode code, StringPiece input) { static_assert( std::is_unsigned::type>::value, "ConversionCode should be unsigned"); - assert((std::size_t)code < kErrorStrings.size()); - const ErrorString& err = kErrorStrings[(std::size_t)code]; + auto index = static_cast(code); + FOLLY_SAFE_CHECK(index < kErrorStrings.size(), "code=", uint64_t(index)); + const ErrorString& err = kErrorStrings[index]; if (code == ConversionCode::EMPTY_INPUT_STRING && input.empty()) { return {err.string, code}; }