diff options
Diffstat (limited to 'qpid/cpp')
-rw-r--r-- | qpid/cpp/src/qpid/types/Variant.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/qpid/cpp/src/qpid/types/Variant.cpp b/qpid/cpp/src/qpid/types/Variant.cpp index 9b981c9171..56a93799ed 100644 --- a/qpid/cpp/src/qpid/types/Variant.cpp +++ b/qpid/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 |