From 60c93fff4d0a7fe75e4e8028fd95ea3a825d5b83 Mon Sep 17 00:00:00 2001 From: Tad Marshall Date: Wed, 12 Dec 2012 13:32:43 -0500 Subject: Use '#pragma warning' to suppress an MSVC warning The Microsoft compiler issues a warning on code that is known at compile time not to be part of the final code; suppress it. --- src/mongo/base/parse_number.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/mongo/base/parse_number.cpp') diff --git a/src/mongo/base/parse_number.cpp b/src/mongo/base/parse_number.cpp index 675c2d82e41..0ecb797670f 100644 --- a/src/mongo/base/parse_number.cpp +++ b/src/mongo/base/parse_number.cpp @@ -128,8 +128,14 @@ namespace mongo { NumberType digitValue = NumberType(_digitValue(str[i])); if (int(digitValue) >= base) return Status(ErrorCodes::FailedToParse, "Bad digit"); + +// MSVC: warning C4146: unary minus operator applied to unsigned type, result still unsigned +// This code is statically known to be dead when NumberType is unsigned, so the warning is not real +#pragma warning(push) +#pragma warning(disable:4146) if ((NumberType(limits::min() / base) > n) || ((limits::min() - NumberType(n * base)) > -digitValue)) { +#pragma warning(pop) return Status(ErrorCodes::FailedToParse, "Underflow"); } -- cgit v1.2.1