Skip to content

Commit e807a76

Browse files
committed
Fixed unit test failure on IBM AIX xlC by hard-coding the maxUInt64AsDouble as double constant instead of relying on double(Value::maxUInt64) which produces an incorrect value.
1 parent d3cd9a7 commit e807a76

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/lib_json/json_value.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ const UInt Value::maxUInt = UInt(-1);
3535
const Int64 Value::minInt64 = Int64( ~(UInt64(-1)/2) );
3636
const Int64 Value::maxInt64 = Int64( UInt64(-1)/2 );
3737
const UInt64 Value::maxUInt64 = UInt64(-1);
38+
// The constant is hard-coded because some compiler have trouble
39+
// converting Value::maxUInt64 to a double correctly (AIX/xlC).
40+
// Assumes that UInt64 is a 64 bits integer.
41+
static const double maxUInt64AsDouble = 18446744073709551615.0;
3842
#endif // defined(JSON_HAS_INT64)
3943
const LargestInt Value::minLargestInt = LargestInt( ~(LargestUInt(-1)/2) );
4044
const LargestInt Value::maxLargestInt = LargestInt( LargestUInt(-1)/2 );
@@ -1443,7 +1447,7 @@ Value::isUInt64() const
14431447
// double, so double(maxUInt64) will be rounded up to 2^64. Therefore we
14441448
// require the value to be strictly less than the limit.
14451449
return value_.real_ >= 0 &&
1446-
value_.real_ < double(maxUInt64) &&
1450+
value_.real_ < maxUInt64AsDouble &&
14471451
IsIntegral(value_.real_);
14481452
default:
14491453
break;

0 commit comments

Comments
 (0)