Open craigminihan opened 9 years ago
gason is forgiving when parsing the json input. No tests fail on bad numbers in a json string, because string2double()
does not use strtod()
, And that internal algorithm indeed has a problem with above-mentioned values.
In my fork, I can conditionally compile, for code to use strtod()
. The above values are correctly parsed and three other tests of 45 do fail in that case. Those 3 tests do use deliberately wrong number input.
If whoever is willing to contribute with debugged string2double()
, I could use that.
In JavaScript (NodeJS) Number.MIN_VALUE is 5e-324 and MAX_VALUE 1.7976931348623157e+308.
These numbers are parsed by gason as 0 and infinity respectively. C++ will handle these as literals quite happily so
string2double
must be causing an underflow and overflow.I replicated this case with simple mods to test-suite.cpp on master:
The output is:
Working case example:
This program prints 'Min: 4.94066e-324, Max: 1.79769e+308'.
I see this problem on an Intel i7 under Debian 8. I guess on some other CPU architectures this test may not fail in this manner.