-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
static analysis warnings #94
Comments
Hi @mlund, thanks for the report. Is it possible to also get the file t.cpp? |
Sure, it's not overly elaborate :-)
|
Indeed... Thanks. :-) |
Unfortunately, I cannot reproduce the warnings with Cppcheck 1.68 on OSX. Furthermore, the line numbers you reported do not match the json.hpp on Github. Could please you attach the json.hpp you used? |
I'm using
|
@mlund just write hash code of the commit you are using. Github will create an url automatically. You can get hash code like this: |
Ahh, I simply downloaded the header from the github webpage, but I get the above warnings on commit 48545f5 with the command |
This is strange. Here is my output with cppcheck 1.70 (trunk version installed via Homebrew on OSX 10.11):
|
Thanks for the persistence; my terminal output is for the 48545f5 checkout is shown below.
|
oh and here's the checksum,
|
This is all weird... If I execute cppcheck (Cppcheck 1.70 dev on OSX 10.11) on the very same files, I get no warnings at all. If I look at the warnings you report, I am puzzled. The last warning (line 4677) for instance, warns about the following functions to throw: static std::string token_type_name(token_type t) noexcept
{
switch (t)
{
case (token_type::uninitialized):
return "<uninitialized>";
case (token_type::literal_true):
return "true literal";
case (token_type::literal_false):
return "false literal";
case (token_type::literal_null):
return "null literal";
case (token_type::value_string):
return "string literal";
case (token_type::value_number):
return "number literal";
case (token_type::begin_array):
return "[";
case (token_type::begin_object):
return "{";
case (token_type::end_array):
return "]";
case (token_type::end_object):
return "}";
case (token_type::name_separator):
return ":";
case (token_type::value_separator):
return ",";
case (token_type::end_of_input):
return "<end of input>";
default:
return "<parse error>";
}
} Interestingly, line 4667 is the switch statement... Anyway. What I take away from the other messages is that I have to many functions marked |
(Oh, stupid me... The function described above indeed can throw, because the constructor for `std::string? can. Sorry about that.) |
An update: I downloaded cppcheck and compiled it myself and I could reproduce the warnings. It seems that the Homebrew version has issues... |
I fixed everything that made sense to me. Thanks for reporting! |
Hi!
I recently ran the static analyser tool
cppcheck
on some code usingnlohmann::json
and got the following warnings.The text was updated successfully, but these errors were encountered: