[Libreoffice-commits] core.git: sc/source

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Tue Oct 22 16:26:55 UTC 2019


 sc/source/core/tool/interpr3.cxx |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit f26178b17691ccc9d3da9c25cec9ef08a633b3a7
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Tue Oct 22 09:52:26 2019 +0200
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Tue Oct 22 18:25:57 2019 +0200

    -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 at redhat.com>

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);
             });


More information about the Libreoffice-commits mailing list