Skip to content

Unused variable in exception class when not using improved diagnostics #2646

Closed
@vpollex

Description

@vpollex

What is the issue you have?

At include/nlohmann/detail/exceptions.hpp:71 or single_include/nlohmann/json.hpp:2662 the parameter leaf_element is unused when the macro JSON_DIAGNOSTICS is undefined. This may cause a compiler to produce a warning or an error.

Please describe the steps to reproduce the issue.

  1. Compile code example below with warnings for unused parameters enabled, e.g. g++ -Wunused-parameter <filename>.

Can you provide a small but working code example?

#include <nlohmann/json.hpp>

int main() {
    return 0;
}

What is the expected behavior?

Compiler does not produce a warning.

And what is the actual behavior instead?

Compiler produces a warning.

Which compiler and operating system are you using?

  • Compiler: g++ 8.3.0 / g++ 10.2.0
  • Operating system: Linux

Which version of the library did you use?

  • latest release version 3.9.1
  • other release - please state the version: ___
  • the develop branch

If you experience a compilation error: can you compile and run the unit tests?

  • yes
  • no - please copy/paste the error message below

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions