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

All enum values not handled in switch cases. ( -Wswitch-enum ) #889

Closed
shamprasadps opened this issue Dec 22, 2017 · 4 comments
Closed

All enum values not handled in switch cases. ( -Wswitch-enum ) #889

shamprasadps opened this issue Dec 22, 2017 · 4 comments
Labels
solution: duplicate the issue is a duplicate; refer to the linked issue instead

Comments

@shamprasadps
Copy link

Bug Report

  • What is the issue you have?
    I am having issues while compiling a C++ program using the json.hpp file. I am using the complier options -Wswitch-enum and -Werror. I see that all the enums are not handled in the switch cases, which is why I am seeing some errors while compiling.

  • Please describe the steps to reproduce the issue. Can you provide a small but working code example?
    Include the json.hpp in the header of a c++ program and compile the program using -Wswitch-enum and -Werror options.

  • What is the expected behavior?
    All enums must be handled and there should be no errors while using these compiler options.

  • And what is the actual behavior instead?
    Actual behaviour: It throws the errors like "src/json.hpp:3005:9: error: enumeration value ‘end_array’ not handled in switch [-Werror=switch-enum]"

  • Which compiler and operating system are you using? Is it a supported compiler?
    Im using a Ubuntu OS and using a supported compiler.

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

  • If you experience a compilation error: can you compile and run the unit tests?
    Not experiencing any issues with the existing compiler options. Errors only when using -Wswitch-enum and -Werror.

Feature Request

  • Describe the feature in as much detail as possible.

  • Include sample usage where appropriate.

@nlohmann
Copy link
Owner

Seems to be a duplicate of #555.

@shamprasadps
Copy link
Author

Yes . It is a duplicate of this issue. I guess it was rejected because not all enums were handled in switch cases and it still reported some warnings. I have added the enums in the switch cases and a default label too.
I do agree that the changes made here to handle -Wswitch-enum for gcc , will throw warnings when clang++ is used with -Wcovered-switch-default option.

@nlohmann
Copy link
Owner

Right - we need to decide whether we want to make Clang or GCC happy, because now we would have

warning: default label in switch which covers all enumeration values [-Wcovered-switch-default]

all over the place.

@nlohmann nlohmann added the solution: duplicate the issue is a duplicate; refer to the linked issue instead label Dec 23, 2017
@nlohmann
Copy link
Owner

I do not like the idea add redundancies to the code to make GCC happy while adding a Clang warning at the same time. See #555 for a discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solution: duplicate the issue is a duplicate; refer to the linked issue instead
Projects
None yet
Development

No branches or pull requests

2 participants