diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2019-08-14 13:54:45 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2019-08-14 15:51:46 +0200 |
commit | f8fdf1df6415dfb3a82e6e632c9d26166984a3d2 (patch) | |
tree | e64691ff22d61e531d0f47b1f13d13ce6c9cb363 /basic | |
parent | e7638f15fc945e6de73876949538682b854fdc41 (diff) |
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@redhat.com>
Diffstat (limited to 'basic')
-rw-r--r-- | basic/source/sbx/sbxvalue.cxx | 8 |
1 files changed, 6 insertions, 2 deletions
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; |