Skip to content
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

cppcheck failing for version 3.1.2 #1101

Closed
psalvaggio opened this issue May 19, 2018 · 11 comments
Closed

cppcheck failing for version 3.1.2 #1101

psalvaggio opened this issue May 19, 2018 · 11 comments
Assignees
Labels
confirmed solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Milestone

Comments

@psalvaggio
Copy link

  • What is the issue you have?

The "make cppcheck" test is failing on version 3.1.2

  • Please describe the steps to reproduce the issue. Can you provide a small but working code example?

Download the .tar.gz for the version, run "make cppcheck"

  • What is the expected behavior?

Passing

  • And what is the actual behavior instead?
[json-3.1.2]$ make cppcheck
cppcheck --enable=warning --inconclusive --force --std=c++11 single_include/nlohmann/json.hpp --error-exitcode=1
Checking single_include/nlohmann/json.hpp ...
[single_include/nlohmann/json.hpp:72]: (error) syntax error
Checking single_include/nlohmann/json.hpp: JSON_CATCH_USER...
Checking single_include/nlohmann/json.hpp: JSON_NOEXCEPTION;_CPPUNWIND;__EXCEPTIONS;__cpp_exceptions...
Checking single_include/nlohmann/json.hpp: JSON_THROW_USER...
Checking single_include/nlohmann/json.hpp: JSON_TRY_USER...
Checking single_include/nlohmann/json.hpp: _HAS_CXX14...
Checking single_include/nlohmann/json.hpp: _HAS_CXX17...
Checking single_include/nlohmann/json.hpp: _MSC_VER...
Checking single_include/nlohmann/json.hpp: _WIN32...
Checking single_include/nlohmann/json.hpp: __APPLE__...
Checking single_include/nlohmann/json.hpp: __GNUC__...
Checking single_include/nlohmann/json.hpp: __GNUC__;__GNUG__...
Checking single_include/nlohmann/json.hpp: __GNUC__;__GNUG__;__clang__...
Checking single_include/nlohmann/json.hpp: __HP_aCC;__HP_cc...
Checking single_include/nlohmann/json.hpp: __IBMCPP__...
Checking single_include/nlohmann/json.hpp: __ICC;__INTEL_COMPILER...
Checking single_include/nlohmann/json.hpp: __PGI...
Checking single_include/nlohmann/json.hpp: __SUNPRO_CC...
Checking single_include/nlohmann/json.hpp: __clang__...
Checking single_include/nlohmann/json.hpp: __linux__...
Checking single_include/nlohmann/json.hpp: __unix__...
make: *** [Makefile:259: cppcheck] Error 1

GCC 7.3.1 on Fedora 27

  • Did you use a released version of the library or the version from the develop branch?

Released

Unit tests are all passing.

@nlohmann
Copy link
Owner

I am aware of this - cppcheck seems to fail parsing the code. I always wanted to open a ticket at cppcheck, but never got to it.

@nlohmann nlohmann self-assigned this May 26, 2018
@nlohmann
Copy link
Owner

The line in question is

template<typename = void, typename = void>
struct adl_serializer;

The problem seems to be the typename = . The following file is a minimal version of the issue:

template<typename = void> struct s;

yielding

Checking bug.hpp ...
[bug.hpp:1]: (error) syntax error

@nlohmann
Copy link
Owner

Unfortunately, it is not trivial to report an issue with cppcheck, see https://trac.cppcheck.net.

I explained the issue on their freenode chat. Let's see how things develop.

@nlohmann
Copy link
Owner

(Using Cppcheck 1.83 by the way)

@nlohmann
Copy link
Owner

If a type name is added before the = void, cppcheck can parse the file.

@theodelrieu
Copy link
Contributor

I guess changing the code to have typename T = void, typename SFINAE = void would be also better to understand what the second template argument is for.

nlohmann added a commit that referenced this issue May 26, 2018
@nlohmann
Copy link
Owner

I applied for a trac account to report the error at cppcheck. In the meantime, I added the type names proposed by @theodelrieu to mitigate the bug from our side.

@nlohmann nlohmann added this to the Release 3.1.3 milestone May 26, 2018
@nlohmann nlohmann added the solution: proposed fix a fix for the issue has been proposed and waits for confirmation label May 26, 2018
@psalvaggio
Copy link
Author

Awesome! FYI, This came up while I was trying to update the Fedora RPM. (https://bugzilla.redhat.com/show_bug.cgi?id=1558490)

@nlohmann
Copy link
Owner

@psalvaggio I had a brief look at the Fedora issue and there seems to be an assertion inside an STL header. I'm not sure whether this is a library issue. But if so, please open a new issue here so we can have a look.

@nlohmann
Copy link
Owner

Closing this issue as original problem with cppcheck has been circumvented with 1c6b332.

@nlohmann
Copy link
Owner

I opened an issue at cppcheck: https://trac.cppcheck.net/ticket/8602

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Projects
None yet
Development

No branches or pull requests

3 participants