summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorMichael Goulish <mgoulish@apache.org>2013-01-10 15:36:02 +0000
committerMichael Goulish <mgoulish@apache.org>2013-01-10 15:36:02 +0000
commit1adf41c11a1b37319e970647a4c1ab1feb690e6f (patch)
treeb2f8d81041bf909cafed436e3fb4e86676daa1ac /cpp/src
parentcbcd20a03e0d654b6832b560eb674dae20894528 (diff)
downloadqpid-python-1adf41c11a1b37319e970647a4c1ab1feb690e6f.tar.gz
JIRA-4531 : Variant.cpp cast of -0 failing with older GCC
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1431435 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/qpid/types/Variant.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/cpp/src/qpid/types/Variant.cpp b/cpp/src/qpid/types/Variant.cpp
index 9b981c9171..56a93799ed 100644
--- a/cpp/src/qpid/types/Variant.cpp
+++ b/cpp/src/qpid/types/Variant.cpp
@@ -113,6 +113,16 @@ class VariantImpl
template<class T> T convertFromString() const
{
const std::string& s = *value.string;
+
+ // The lexical cast below is throwing when the type
+ // is signed and the value is negative-zero. Bug, I guess.
+ // So short-circuit it here. Negative zero is zero.
+ double dbl_val = atof ( s.c_str() );
+ if ( ( dbl_val == 0 ) && ( 0 == s.find('-') ) ) {
+ T r = 0;
+ return r;
+ }
+
try {
T r = boost::lexical_cast<T>(s);
//lexical_cast won't fail if string is a negative number and T is unsigned