summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2019-10-22 09:52:26 +0200
committerStephan Bergmann <sbergman@redhat.com>2019-10-22 18:25:57 +0200
commitf26178b17691ccc9d3da9c25cec9ef08a633b3a7 (patch)
treee669b446149e52ef066d9d9d27ec433731b07262
parentbef71336399f1dc678eee16b5d6d7bf26a17f491 (diff)
-Werror,-Wimplicit-int-float-conversion
> sc/source/core/tool/interpr3.cxx:3659:36: error: implicit conversion from 'unsigned long' to 'double' changes value from 18446744073709551615 to 18446744073709551616 [-Werror,-Wimplicit-int-float-conversion] > if (f < 1.0 || f > std::numeric_limits<SCSIZE>::max()) > ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ since 475165e431b5392e426db0de4cea50efc2513875 "Resolves: tdf#127982 SMALL()/LARGE() rank array can be larger than data array" (This supersedes 1b0cba8c2cd672b0d5a59a215961c5136a6e656b "-Wimplicit-int-float-conversion", which would have incurred UB if f is larger than std::numeric_limits<SCSIZE>::max().) Change-Id: I1eeb75d73169ac89ec4bf9562edcf99d9925f607 Reviewed-on: https://gerrit.libreoffice.org/81309 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
-rw-r--r--sc/source/core/tool/interpr3.cxx3
1 files changed, 2 insertions, 1 deletions
diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index ae99d1a79ef6..f219beca9386 100644
--- a/sc/source/core/tool/interpr3.cxx
+++ b/sc/source/core/tool/interpr3.cxx
@@ -37,6 +37,7 @@
#include <vector>
#include <algorithm>
#include <comphelper/random.hxx>
+#include <o3tl/float_int_conversion.hxx>
#include <osl/diagnose.h>
#include <basegfx/numeric/ftools.hxx>
@@ -3656,7 +3657,7 @@ void ScInterpreter::CalculateSmallLarge(bool bSmall)
[](double f) {
f = rtl::math::approxFloor(f);
// Valid ranks are >= 1.
- if (f < 1.0 || static_cast<SCSIZE>(f) > std::numeric_limits<SCSIZE>::max())
+ if (f < 1.0 || !o3tl::convertsToAtMost(f, std::numeric_limits<SCSIZE>::max()))
return static_cast<SCSIZE>(0);
return static_cast<SCSIZE>(f);
});