You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a small bug in the following area of json.cpp:
if (attempt_cast(std::strtoll(reinterpret_cast<typenamestring_t::const_pointer>(m_start),
&endptr, 10), result.m_value.number_unsigned))
Here result.m_value.number_unsigned should be result.m_value.number_integer.
Then in unit.hpp there is another bug:
// integer object creation - expected to wrap and still be stored as an integer
j = -2147483649LL; // -2^31-1CHECK(static_cast<int>(j.type()) == static_cast<int>(custom_json::value_t::number_integer));
CHECK(j.get<int32_t>() == 2147483647.0); // Wrap// integer parsing - expected to overflow and be stored as a float
j = custom_json::parse("-2147483648"); // -2^31CHECK(static_cast<int>(j.type()) == static_cast<int>(custom_json::value_t::number_float));
CHECK(j.get<float>() == -2147483648.0);
The second test for parsing uses an incorrect value. Instead of -2147483648 it should read -2147483649.
The previous value -2147483648 should not have wrapped as was intended however the bug in json.hpp had the effect of causing the cast to fail anyway. The second error effectively hid the first error so the unit test passed.
One other small error is that all of the floating point comparisons in this section should have an 'f' after the literals otherwise they are double literals - so the above comparison would read CHECK(j.get<float>() == -2147483650.0f.
The text was updated successfully, but these errors were encountered:
twelsby
pushed a commit
to twelsby/json
that referenced
this issue
Jan 30, 2016
There is a small bug in the following area of json.cpp:
Here
result.m_value.number_unsigned
should beresult.m_value.number_integer
.Then in unit.hpp there is another bug:
The second test for parsing uses an incorrect value. Instead of
-2147483648
it should read-2147483649
.The previous value
-2147483648
should not have wrapped as was intended however the bug in json.hpp had the effect of causing the cast to fail anyway. The second error effectively hid the first error so the unit test passed.One other small error is that all of the floating point comparisons in this section should have an 'f' after the literals otherwise they are double literals - so the above comparison would read
CHECK(j.get<float>() == -2147483650.0f
.The text was updated successfully, but these errors were encountered: