Skip to content

Commit 95f120f

Browse files
committed
For gcc>=6 JSON_USE_INT64_DOUBLE_CONVERSION
1 parent 9a4b1e3 commit 95f120f

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

include/json/config.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@
114114
#define JSONCPP_DEPRECATED(message)
115115
#endif // if !defined(JSONCPP_DEPRECATED)
116116

117+
#if __GNUC__ >= 6
118+
# define JSON_USE_INT64_DOUBLE_CONVERSION 1
119+
#endif
120+
117121
namespace Json {
118122
typedef int Int;
119123
typedef unsigned int UInt;

src/lib_json/json_value.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,8 @@ float Value::asFloat() const {
784784
#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
785785
return static_cast<float>(value_.uint_);
786786
#else // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
787-
return integerToDouble(value_.uint_);
787+
// This can fail (silently?) if the value is bigger than MAX_FLOAT.
788+
return static_cast<float>(integerToDouble(value_.uint_));
788789
#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
789790
case realValue:
790791
return static_cast<float>(value_.real_);

0 commit comments

Comments
 (0)