summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2013-03-26 23:22:26 +0100
committerStephan Bergmann <sbergman@redhat.com>2013-03-26 23:26:46 +0100
commit30be686ddee70c5aa661abfc8eb2cb6f6fdc4752 (patch)
tree759f328af0356baf62ee0cbbb367f3c4ff5f8c87 /sal
parentc1563bc6d2143b9881b93f912bd0e008d3e86b14 (diff)
Could the failing MSVC tinderbox be due to implementation-defined /
...for negative integers in < C++11? Rather unlikely, but lets see... Change-Id: I9abfcbf2c0e409fab4c77b62e5f734d3c2cc2719
Diffstat (limited to 'sal')
-rw-r--r--sal/rtl/strtmpl.cxx24
1 files changed, 22 insertions, 2 deletions
diff --git a/sal/rtl/strtmpl.cxx b/sal/rtl/strtmpl.cxx
index 6859af15b31e..455a6aebd540 100644
--- a/sal/rtl/strtmpl.cxx
+++ b/sal/rtl/strtmpl.cxx
@@ -941,8 +941,28 @@ namespace {
bNeg = sal_False;
}
- const T nDiv = bNeg ? -(std::numeric_limits<T>::min()/nRadix) : (std::numeric_limits<T>::max()/nRadix);
- const sal_Int16 nMod = bNeg ? -(std::numeric_limits<T>::min()%nRadix) : (std::numeric_limits<T>::max()%nRadix);
+ T nDiv;
+ sal_Int16 nMod;
+ if ( bNeg )
+ {
+ nDiv = std::numeric_limits<T>::min() / nRadix;
+ nMod = std::numeric_limits<T>::min() % nRadix;
+ // Cater for C++03 implementations that round the quotient down
+ // instead of truncating towards zero as mandated by C++11:
+ if ( nMod > 0 )
+ {
+ --nDiv;
+ nMod -= nRadix;
+ }
+ nDiv = -nDiv;
+ nMod = -nMod;
+ }
+ else
+ {
+ nDiv = std::numeric_limits<T>::max() / nRadix;
+ nMod = std::numeric_limits<T>::max() % nRadix;
+ }
+
while ( *pStr )
{
nDigit = rtl_ImplGetDigit( IMPL_RTL_USTRCODE( *pStr ), nRadix );