-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clang-3.6.2] string/sstream with number to json issue #107
Comments
Hi Vladimir, unfortunately, I cannot reproduce this. I tried with Clang 3.6.2 from Homebrew (package Cheers, |
Niels, That is a little bit strange. I logged in Linux and this bug with did not take place there. |
I'm having issues with parsing numbers as well, but with MSVC 2015. Seems like strtold considers the trailing comma to be part of the number, causing endptr to go past m_cursor, so the function get_number() returns NAN. |
Can you provide me with a concrete example? |
Not yet, because parsing the same string seems to work ok in a clean project... |
This seems to depend on the current system locale. If I change the number format from Finnish to US and run the program, the comma won't be included in the number. Parsing works correctly in a clean Win32 console project regardless of the locale though. |
I made a change in the string-to-float conversion to make it locale-independent. Could you please check if the issue still exists, @maksis? |
It seems to work correctly now |
@nlohmann thank you! Now it works fine. |
However, the build on ApoVeyor fails. :-( |
As I can see it is because of the quite big precision of returned value. Is it the case to use something like this: long double foo(long double v) {
std::stringstream ss;
ss << v;
ss.precision(6);
ss >> v;
return v;
}
int main() {
long double a = 10.1238127638712638;
std::cout << foo(a) << std::endl;
return 0;
} |
Unfortunately, this does not help. The issue is the following
The Windows build fails to parse the number |
I reverted the fix. It has some unpredictable behavior, and compatibility to MSVC would break. |
:-( |
Hello Niels. That issue could be closed, because |
Thanks for getting back and telling me! :-) |
Dear Niels,
I have a library for working with some translate API. By using curl I form request to the server and obtain a string in the format
{"code":200,"lang":"ru-en","text":[hello]}
. After a while I met the issue that my library which had been build with clang dropped withSegmentation fault
error.Below my test code which works well with
g++ (4.9.2 and 5.2.0)
, but not withclang++ (3.6.2)
:And also tested such case:
std::string s{"{ \"code\" : 200 }"}; json d; d = json::parse(s);
My current clang is
version 3.6.2 (tags/RELEASE_362/final)
. I will test it with other version and will tell you if something changes.The text was updated successfully, but these errors were encountered: