summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Marks <gabriel.marks@mongodb.com>2021-10-29 21:07:18 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-10-29 22:15:17 +0000
commit83b2c0ddd983c0a685ca91fe545930723b3e13fe (patch)
tree79e1bd3dbf0304d3672755fad7058c0cf55ed28c
parent486ea6c419d62e9e47b3378baedfcedfdf77e48d (diff)
downloadmongo-83b2c0ddd983c0a685ca91fe545930723b3e13fe.tar.gz
SERVER-60199 Attempt to fix Coverity defect
-rw-r--r--src/mongo/bson/bsonelement.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/mongo/bson/bsonelement.h b/src/mongo/bson/bsonelement.h
index e4485d19233..e519152202b 100644
--- a/src/mongo/bson/bsonelement.h
+++ b/src/mongo/bson/bsonelement.h
@@ -1056,7 +1056,8 @@ Status BSONElement::tryCoerce(T* out) const {
if (!std::isfinite(d)) {
return {ErrorCodes::BadValue, "Unable to coerce NaN/Inf to integral type"};
}
- bool sameMax = std::numeric_limits<T>::max() == std::numeric_limits<long long>::max();
+ constexpr bool sameMax =
+ std::numeric_limits<T>::max() == std::numeric_limits<long long>::max();
if ((!sameMax && d > static_cast<double>(std::numeric_limits<T>::max())) ||
(sameMax && d >= static_cast<double>(std::numeric_limits<T>::max())) ||
(d < std::numeric_limits<T>::lowest())) {