You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
All enum values not handled in switch cases. ( -Wswitch-enum ) #889
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.
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.
Activity
nlohmann commentedon Dec 22, 2017
Seems to be a duplicate of #555.
shamprasadps commentedon Dec 22, 2017
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 commentedon Dec 23, 2017
Right - we need to decide whether we want to make Clang or GCC happy, because now we would have
all over the place.
nlohmann commentedon Dec 28, 2017
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.