From 1b3728314848c3b19451ca713ccc4a7463655281 Mon Sep 17 00:00:00 2001 From: Michael Goulish Date: Thu, 10 Jan 2013 15:36:02 +0000 Subject: 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 --- cpp/src/qpid/types/Variant.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'cpp/src') 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 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(s); //lexical_cast won't fail if string is a negative number and T is unsigned -- cgit v1.2.1