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

Compiler warns of implicit fallthrough when defining preprocessor macro NDEBUG #2348

Closed
2 of 5 tasks
vpollex opened this issue Aug 10, 2020 · 0 comments · Fixed by #2349
Closed
2 of 5 tasks

Compiler warns of implicit fallthrough when defining preprocessor macro NDEBUG #2348

vpollex opened this issue Aug 10, 2020 · 0 comments · Fixed by #2349
Assignees
Labels
confirmed kind: bug release item: 🔨 further change solution: proposed fix a fix for the issue has been proposed and waits for confirmation

Comments

@vpollex
Copy link

vpollex commented Aug 10, 2020

What is the issue you have?

GCC produces a warning that statement json.hpp:8394 may fall through when preprocessor macro NDEBUG is defined.

Please describe the steps to reproduce the issue.

  1. Compile code example below with warning for implicit fallthrough enabled and defined preprocessor macro NDEBUG such that it uses the single-header file, eg. g++ -Wextra -DNDEBUG <filename>

Can you provide a small but working code example?

#include <nlohmann/json.hpp>

int main() {
        nlohmann::json j1 = R"({"compact": true, "schema": 0})"_json;
        nlohmann::json j2 = nlohmann::json::from_msgpack(nlohmann::json::to_msgpack(j1));
        return 0;
}

What is the expected behavior?

Compiler does not produce a warning, because a statement may fall through

And what is the actual behavior instead?

Compiler produces a warning, because a statement may fall through

Which compiler and operating system are you using?

  • Compiler: g++ 7.5.0 / g++ 8.3.0 / g++ 10.1.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
@nlohmann nlohmann self-assigned this Aug 10, 2020
@nlohmann nlohmann added the solution: proposed fix a fix for the issue has been proposed and waits for confirmation label Aug 10, 2020
@nlohmann nlohmann added this to the Release 3.9.2 milestone Aug 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed kind: bug release item: 🔨 further change solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants