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

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Wed Aug 14 13:52:51 UTC 2019


 basic/source/sbx/sbxvalue.cxx |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

New commits:
commit f8fdf1df6415dfb3a82e6e632c9d26166984a3d2
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Wed Aug 14 13:54:45 2019 +0200
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Wed Aug 14 15:51:46 2019 +0200

    Fix Clang 10 -Werror,-Wimplicit-int-float-conversion
    
    > basic/source/sbx/sbxvalue.cxx:1038:58: error: implicit conversion from 'sal_Int64' (aka 'long') to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Werror,-Wimplicit-int-float-conversion]
    >                             if( dTest < SAL_MIN_INT64 || SAL_MAX_INT64 < dTest)
    >                                                          ^~~~~~~~~~~~~ ~
    > basic/source/sbx/sbxvalue.cxx:1065:58: error: implicit conversion from 'sal_Int64' (aka 'long') to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Werror,-Wimplicit-int-float-conversion]
    >                             if( dTest < SAL_MIN_INT64 || SAL_MAX_INT64 < dTest)
    >                                                          ^~~~~~~~~~~~~ ~
    
    Change-Id: Ic1e88ae0e0cbc58bec0742d73fa40bfa0ff88858
    Reviewed-on: https://gerrit.libreoffice.org/77453
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/basic/source/sbx/sbxvalue.cxx b/basic/source/sbx/sbxvalue.cxx
index 37f8cffbf413..1d29fa3ca5ab 100644
--- a/basic/source/sbx/sbxvalue.cxx
+++ b/basic/source/sbx/sbxvalue.cxx
@@ -20,6 +20,8 @@
 #include <config_features.h>
 
 #include <math.h>
+
+#include <o3tl/float_int_conversion.hxx>
 #include <tools/debug.hxx>
 #include <tools/stream.hxx>
 #include <sal/log.hxx>
@@ -1035,7 +1037,8 @@ bool SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp )
                             }
                             // second overflow check: see if unscaled product overflows - if so use doubles
                             dTest = static_cast<double>(aL.nInt64) * static_cast<double>(aR.nInt64);
-                            if( dTest < SAL_MIN_INT64 || SAL_MAX_INT64 < dTest)
+                            if( !(o3tl::convertsToAtLeast(dTest, SAL_MIN_INT64)
+                                  && o3tl::convertsToAtMost(dTest, SAL_MAX_INT64)))
                             {
                                 aL.nInt64 = static_cast<sal_Int64>( dTest / double(CURRENCY_FACTOR) );
                                 break;
@@ -1062,7 +1065,8 @@ bool SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp )
                             }
                             // second overflow check: see if scaled dividend overflows - if so use doubles
                             dTest = static_cast<double>(aL.nInt64) * double(CURRENCY_FACTOR);
-                            if( dTest < SAL_MIN_INT64 || SAL_MAX_INT64 < dTest)
+                            if( !(o3tl::convertsToAtLeast(dTest, SAL_MIN_INT64)
+                                  && o3tl::convertsToAtMost(dTest, SAL_MAX_INT64)))
                             {
                                 aL.nInt64 = static_cast<sal_Int64>(dTest / static_cast<double>(aR.nInt64));
                                 break;


More information about the Libreoffice-commits mailing list