Static analysis tool cppcheck prints warning on json.h
Closed this issue · 3 comments
Hello, not a problem or bug per-se, but in any case I report it, I have a 2021 version, single-header file of this nice parser, I use it a lot for my github projects, working just fine. Today I run cppcheck using latest version on Ubuntu 22.04 and this warning was printed:
cppcheck --version
Cppcheck 2.7
The warning:
src/json.h:1259:18: error: Exception thrown in function declared not to throw exceptions. [throwInNoexceptFunction]
return has_key(as_object(v), key);
^
I see that this parser is divided into several .h files, and wonder how I have a single-header version? I don't recall creating a single file myself, whatever.
I will try to use the current Master version of the parser and run again cppcheck, nevertheless I checked the latest code and has_key keeps marked as noexcept and contains pretty much the same code as my old version.
Regards,
CPPServer
So it was single file at one point but I relatively recently broke it up to aid in an attempt to better organize it and possible improve the implementation further.
No the less, has_key
is indeed marked noexcept
when it can throw an exceptio, so I'll tweak the code to fix that.
Thanks!
Should be fixed in the main branch