open-source-parsers / open-source-parsers/jsoncpp
Large floats not accepted anymore
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 8.9k
- Forks
- 2.7k
- Avg merge
- 31m
- Merged PRs (30d)
- 1
Description
Describe the bug
Version 1.9.2 no longer accepts 1+e9999 (or 2e+308 and anything above), regardless of allowSpecialFloats setting.
To Reproduce
Steps to reproduce the behavior:
#include <iostream>
#include <json/json.h>
#include <sstream>
int main(int argc, const char* argv[])
{
Json::CharReaderBuilder reader;
reader["allowSpecialFloats"] = true; // Makes no difference
std::string s = "1e+9999";
Json::Value val;
std::string errors;
std::stringstream json(s);
if (Json::parseFromStream(reader, json, &val, &errors)) {
std::cout << s << " -> " << val.asDouble() << "\n";
} else {
std::cout << errors;
}
return 0;
}
Expected behavior
1e+9999 -> inf
Actual behavior:
* Line 1, Column 1
'1e+9999' is not a number.
Desktop (please complete the following information):
- OS: Fedora 34
- Meson version 0.59.1
- Ninja version 1.10.2
Additional context
- Version 1.9.1 accepts value
1e+9999as infinite, regardless ofallowSpecialFloatssetting. - Version 1.9.2 no longer accepts
2e+308or above, regardless ofallowSpecialFloatssetting.
Specifically breaking change seems to be commit 645cd0412c "Number fixes (#1053)".
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the Json::CharReaderBuilder and parseFromStream entry points, then inspect the number-handling change in commit 645cd0412c. Reproduce the issue with 1e+9999 and 2e+308, and add or update a regression test showing that these values are accepted as infinity when appropriate.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100