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

Fix some "enumeration values not explicitly handled in switch" warnings #555

Closed
wants to merge 4 commits into from

Conversation

cmaglie
Copy link

@cmaglie cmaglie commented Apr 15, 2017

This change aims to remove the warnings emitted with the -Wswitch-enum flag and remove the default case.

The motivation for removing the default case is that I want a compiler warning if new values are added to an enumeration and there are switch/case that needs to be updated to handle them.
Moreover in some cases I added an assert(false) at the end of the switch/case: this means that an invalid enum value has been passed when this should not happen.

./src/json.hpp:1968:21: warning: enumeration value 'discarded' not explicitly handled in switch [-Wswitch-enum]
./src/json.hpp:9339:21: warning: enumeration values 'number_integer', 'number_unsigned',
      and 'number_float' not explicitly handled in switch [-Wswitch-enum]
In this case the switch is useless since the other cases
are already excluded by the initial asserts.
Removing the switch altogether seems the best way forward.
./src/json.hpp:2821:17: warning: 6 enumeration values not explicitly
      handled in switch: 'null', 'boolean', 'number_integer'... [-Wswitch-enum]
@coveralls
Copy link

Coverage Status

Coverage decreased (-9.0e-05%) to 99.866% when pulling 54c9669 on cmaglie:fix-some-warning into 42b4cdd on nlohmann:develop.

@nlohmann
Copy link
Owner

I'm not sure what you are fixing here, but there are still warnings when compiled with -Wswitch-enum:

$ make CXXFLAGS="-Wswitch-enum -std=c++11"
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C test
[CXX]   src/unit-algorithms.o
In file included from src/unit-algorithms.cpp:31:0:
../src/json.hpp: In instantiation of ‘nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::size_type nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::size() const [with ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::size_type = long unsigned int]’:
src/unit-algorithms.cpp:43:13:   required from here
../src/json.hpp:5335:9: warning: enumeration value ‘string’ not handled in switch [-Wswitch-enum]
         switch (m_type)
         ^~~~~~
../src/json.hpp:5335:9: warning: enumeration value ‘boolean’ not handled in switch [-Wswitch-enum]
../src/json.hpp:5335:9: warning: enumeration value ‘number_integer’ not handled in switch [-Wswitch-enum]
../src/json.hpp:5335:9: warning: enumeration value ‘number_unsigned’ not handled in switch [-Wswitch-enum]
../src/json.hpp:5335:9: warning: enumeration value ‘number_float’ not handled in switch [-Wswitch-enum]
../src/json.hpp:5335:9: warning: enumeration value ‘discarded’ not handled in switch [-Wswitch-enum]
../src/json.hpp: In instantiation of ‘bool nlohmann::operator==(nlohmann::basic_json<>::const_reference, nlohmann::basic_json<>::const_reference)’:
src/unit-algorithms.cpp:106:17:   required from here
../src/json.hpp:6163:13: warning: enumeration value ‘discarded’ not handled in switch [-Wswitch-enum]
             switch (lhs_type)
             ^~~~~~
../src/json.hpp: In instantiation of ‘nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>::reference nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>::operator*() const [with U = nlohmann::basic_json<>; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>::reference = nlohmann::basic_json<>&]’:
src/unit-algorithms.cpp:131:13:   required from here
../src/json.hpp:9843:13: warning: enumeration value ‘string’ not handled in switch [-Wswitch-enum]
             switch (m_object->m_type)
             ^~~~~~
../src/json.hpp:9843:13: warning: enumeration value ‘boolean’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9843:13: warning: enumeration value ‘number_integer’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9843:13: warning: enumeration value ‘number_unsigned’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9843:13: warning: enumeration value ‘number_float’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9843:13: warning: enumeration value ‘discarded’ not handled in switch [-Wswitch-enum]
../src/json.hpp: In instantiation of ‘bool nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>::operator==(const nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>&) const [with U = nlohmann::basic_json<>; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer]’:
src/unit-algorithms.cpp:185:13:   required from here
../src/json.hpp:10008:13: warning: enumeration value ‘null’ not handled in switch [-Wswitch-enum]
             switch (m_object->m_type)
             ^~~~~~
../src/json.hpp:10008:13: warning: enumeration value ‘string’ not handled in switch [-Wswitch-enum]
../src/json.hpp:10008:13: warning: enumeration value ‘boolean’ not handled in switch [-Wswitch-enum]
../src/json.hpp:10008:13: warning: enumeration value ‘number_integer’ not handled in switch [-Wswitch-enum]
../src/json.hpp:10008:13: warning: enumeration value ‘number_unsigned’ not handled in switch [-Wswitch-enum]
../src/json.hpp:10008:13: warning: enumeration value ‘number_float’ not handled in switch [-Wswitch-enum]
../src/json.hpp:10008:13: warning: enumeration value ‘discarded’ not handled in switch [-Wswitch-enum]
../src/json.hpp: In instantiation of ‘nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>::reference nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>::operator[](nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>::difference_type) const [with U = nlohmann::basic_json<>; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>::reference = nlohmann::basic_json<>&; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>::difference_type = long int]’:
src/unit-algorithms.cpp:215:13:   required from here
../src/json.hpp:10193:13: warning: enumeration value ‘string’ not handled in switch [-Wswitch-enum]
             switch (m_object->m_type)
             ^~~~~~
../src/json.hpp:10193:13: warning: enumeration value ‘boolean’ not handled in switch [-Wswitch-enum]
../src/json.hpp:10193:13: warning: enumeration value ‘number_integer’ not handled in switch [-Wswitch-enum]
../src/json.hpp:10193:13: warning: enumeration value ‘number_unsigned’ not handled in switch [-Wswitch-enum]
../src/json.hpp:10193:13: warning: enumeration value ‘number_float’ not handled in switch [-Wswitch-enum]
../src/json.hpp:10193:13: warning: enumeration value ‘discarded’ not handled in switch [-Wswitch-enum]
../src/json.hpp: In instantiation of ‘nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>::iter_impl(nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>::pointer) [with U = nlohmann::basic_json<>; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>::pointer = nlohmann::basic_json<>*]’:
../src/json.hpp:4942:18:   required from ‘nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iterator nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::begin() [with ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iterator = nlohmann::basic_json<>::iter_impl<nlohmann::basic_json<> >]’
src/unit-algorithms.cpp:43:13:   required from here
../src/json.hpp:9697:13: warning: enumeration value ‘null’ not handled in switch [-Wswitch-enum]
             switch (m_object->m_type)
             ^~~~~~
../src/json.hpp:9697:13: warning: enumeration value ‘string’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9697:13: warning: enumeration value ‘boolean’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9697:13: warning: enumeration value ‘number_integer’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9697:13: warning: enumeration value ‘number_unsigned’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9697:13: warning: enumeration value ‘number_float’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9697:13: warning: enumeration value ‘discarded’ not handled in switch [-Wswitch-enum]
../src/json.hpp: In instantiation of ‘void nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>::set_begin() [with U = nlohmann::basic_json<>; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer]’:
../src/json.hpp:4943:9:   required from ‘nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iterator nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::begin() [with ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iterator = nlohmann::basic_json<>::iter_impl<nlohmann::basic_json<> >]’
src/unit-algorithms.cpp:43:13:   required from here
../src/json.hpp:9775:13: warning: enumeration value ‘string’ not handled in switch [-Wswitch-enum]
             switch (m_object->m_type)
             ^~~~~~
../src/json.hpp:9775:13: warning: enumeration value ‘boolean’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9775:13: warning: enumeration value ‘number_integer’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9775:13: warning: enumeration value ‘number_unsigned’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9775:13: warning: enumeration value ‘number_float’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9775:13: warning: enumeration value ‘discarded’ not handled in switch [-Wswitch-enum]
../src/json.hpp: In instantiation of ‘void nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>::set_end() [with U = nlohmann::basic_json<>; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer]’:
../src/json.hpp:5014:9:   required from ‘nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iterator nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::end() [with ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iterator = nlohmann::basic_json<>::iter_impl<nlohmann::basic_json<> >]’
src/unit-algorithms.cpp:43:13:   required from here
../src/json.hpp:9812:13: warning: enumeration value ‘null’ not handled in switch [-Wswitch-enum]
             switch (m_object->m_type)
             ^~~~~~
../src/json.hpp:9812:13: warning: enumeration value ‘string’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9812:13: warning: enumeration value ‘boolean’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9812:13: warning: enumeration value ‘number_integer’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9812:13: warning: enumeration value ‘number_unsigned’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9812:13: warning: enumeration value ‘number_float’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9812:13: warning: enumeration value ‘discarded’ not handled in switch [-Wswitch-enum]
../src/json.hpp: In instantiation of ‘nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>::iter_impl(nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>::pointer) [with U = const nlohmann::basic_json<>; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>::pointer = const nlohmann::basic_json<>*]’:
../src/json.hpp:4982:24:   required from ‘nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::const_iterator nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::cbegin() const [with ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::const_iterator = nlohmann::basic_json<>::iter_impl<const nlohmann::basic_json<> >]’
src/unit-algorithms.cpp:83:46:   required from here
../src/json.hpp:9697:13: warning: enumeration value ‘null’ not handled in switch [-Wswitch-enum]
             switch (m_object->m_type)
             ^~~~~~
../src/json.hpp:9697:13: warning: enumeration value ‘string’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9697:13: warning: enumeration value ‘boolean’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9697:13: warning: enumeration value ‘number_integer’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9697:13: warning: enumeration value ‘number_unsigned’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9697:13: warning: enumeration value ‘number_float’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9697:13: warning: enumeration value ‘discarded’ not handled in switch [-Wswitch-enum]
../src/json.hpp: In instantiation of ‘void nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>::set_begin() [with U = const nlohmann::basic_json<>; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer]’:
../src/json.hpp:4983:9:   required from ‘nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::const_iterator nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::cbegin() const [with ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::const_iterator = nlohmann::basic_json<>::iter_impl<const nlohmann::basic_json<> >]’
src/unit-algorithms.cpp:83:46:   required from here
../src/json.hpp:9775:13: warning: enumeration value ‘string’ not handled in switch [-Wswitch-enum]
             switch (m_object->m_type)
             ^~~~~~
../src/json.hpp:9775:13: warning: enumeration value ‘boolean’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9775:13: warning: enumeration value ‘number_integer’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9775:13: warning: enumeration value ‘number_unsigned’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9775:13: warning: enumeration value ‘number_float’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9775:13: warning: enumeration value ‘discarded’ not handled in switch [-Wswitch-enum]
../src/json.hpp: In instantiation of ‘void nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>::set_end() [with U = const nlohmann::basic_json<>; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer]’:
../src/json.hpp:5054:9:   required from ‘nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::const_iterator nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::cend() const [with ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::const_iterator = nlohmann::basic_json<>::iter_impl<const nlohmann::basic_json<> >]’
src/unit-algorithms.cpp:83:62:   required from here
../src/json.hpp:9812:13: warning: enumeration value ‘null’ not handled in switch [-Wswitch-enum]
             switch (m_object->m_type)
             ^~~~~~
../src/json.hpp:9812:13: warning: enumeration value ‘string’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9812:13: warning: enumeration value ‘boolean’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9812:13: warning: enumeration value ‘number_integer’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9812:13: warning: enumeration value ‘number_unsigned’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9812:13: warning: enumeration value ‘number_float’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9812:13: warning: enumeration value ‘discarded’ not handled in switch [-Wswitch-enum]
../src/json.hpp: In instantiation of ‘nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>& nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>::operator++() [with U = const nlohmann::basic_json<>; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer]’:
/Users/niels/Documents/projects/gcc/include/c++/7.0.1/bits/stl_algo.h:3883:33:   required from ‘_Funct std::for_each(_IIter, _IIter, _Funct) [with _IIter = nlohmann::basic_json<>::iter_impl<const nlohmann::basic_json<> >; _Funct = ____C_A_T_C_H____T_E_S_T____34()::<lambda(const json&)>]’
src/unit-algorithms.cpp:89:18:   required from here
../src/json.hpp:9927:13: warning: enumeration value ‘null’ not handled in switch [-Wswitch-enum]
             switch (m_object->m_type)
             ^~~~~~
../src/json.hpp:9927:13: warning: enumeration value ‘string’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9927:13: warning: enumeration value ‘boolean’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9927:13: warning: enumeration value ‘number_integer’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9927:13: warning: enumeration value ‘number_unsigned’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9927:13: warning: enumeration value ‘number_float’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9927:13: warning: enumeration value ‘discarded’ not handled in switch [-Wswitch-enum]
../src/json.hpp: In instantiation of ‘nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>::reference nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>::operator*() const [with U = const nlohmann::basic_json<>; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>::reference = const nlohmann::basic_json<>&]’:
/Users/niels/Documents/projects/gcc/include/c++/7.0.1/bits/stl_algo.h:3884:6:   required from ‘_Funct std::for_each(_IIter, _IIter, _Funct) [with _IIter = nlohmann::basic_json<>::iter_impl<const nlohmann::basic_json<> >; _Funct = ____C_A_T_C_H____T_E_S_T____34()::<lambda(const json&)>]’
src/unit-algorithms.cpp:89:18:   required from here
../src/json.hpp:9843:13: warning: enumeration value ‘string’ not handled in switch [-Wswitch-enum]
             switch (m_object->m_type)
             ^~~~~~
../src/json.hpp:9843:13: warning: enumeration value ‘boolean’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9843:13: warning: enumeration value ‘number_integer’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9843:13: warning: enumeration value ‘number_unsigned’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9843:13: warning: enumeration value ‘number_float’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9843:13: warning: enumeration value ‘discarded’ not handled in switch [-Wswitch-enum]
../src/json.hpp: In instantiation of ‘nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>& nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>::operator++() [with U = nlohmann::basic_json<>; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer]’:
/Users/niels/Documents/projects/gcc/include/c++/7.0.1/bits/stl_algo.h:3883:33:   required from ‘_Funct std::for_each(_IIter, _IIter, _Funct) [with _IIter = nlohmann::basic_json<>::iter_impl<nlohmann::basic_json<> >; _Funct = ____C_A_T_C_H____T_E_S_T____34()::<lambda(nlohmann::json&)>]’
src/unit-algorithms.cpp:104:68:   required from here
../src/json.hpp:9927:13: warning: enumeration value ‘null’ not handled in switch [-Wswitch-enum]
             switch (m_object->m_type)
             ^~~~~~
../src/json.hpp:9927:13: warning: enumeration value ‘string’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9927:13: warning: enumeration value ‘boolean’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9927:13: warning: enumeration value ‘number_integer’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9927:13: warning: enumeration value ‘number_unsigned’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9927:13: warning: enumeration value ‘number_float’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9927:13: warning: enumeration value ‘discarded’ not handled in switch [-Wswitch-enum]
../src/json.hpp: In instantiation of ‘nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>& nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>::operator+=(nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>::difference_type) [with U = nlohmann::basic_json<>; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>::difference_type = long int]’:
../src/json.hpp:10143:20:   required from ‘nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U> nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>::operator+(nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>::difference_type) [with U = nlohmann::basic_json<>; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>::difference_type = long int]’
src/unit-algorithms.cpp:204:60:   required from here
../src/json.hpp:10104:13: warning: enumeration value ‘null’ not handled in switch [-Wswitch-enum]
             switch (m_object->m_type)
             ^~~~~~
../src/json.hpp:10104:13: warning: enumeration value ‘string’ not handled in switch [-Wswitch-enum]
../src/json.hpp:10104:13: warning: enumeration value ‘boolean’ not handled in switch [-Wswitch-enum]
../src/json.hpp:10104:13: warning: enumeration value ‘number_integer’ not handled in switch [-Wswitch-enum]
../src/json.hpp:10104:13: warning: enumeration value ‘number_unsigned’ not handled in switch [-Wswitch-enum]
../src/json.hpp:10104:13: warning: enumeration value ‘number_float’ not handled in switch [-Wswitch-enum]
../src/json.hpp:10104:13: warning: enumeration value ‘discarded’ not handled in switch [-Wswitch-enum]
../src/json.hpp: In instantiation of ‘nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer> nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::parser::parse_internal(bool) [with ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer]’:
../src/json.hpp:12220:47:   required from ‘nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer> nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::parser::parse() [with ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer]’
../src/json.hpp:7403:37:   required from ‘static nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer> nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::parse(IteratorType, IteratorType, nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::parser_callback_t) [with IteratorType = const char*; typename std::enable_if<std::is_base_of<std::random_access_iterator_tag, typename std::iterator_traits<_InputIterator>::iterator_category>::value, int>::type <anonymous> = 0; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::parser_callback_t = std::function<bool(int, nlohmann::basic_json<>::parse_event_t, nlohmann::basic_json<>&)>]’
../src/json.hpp:13948:42:   required from here
../src/json.hpp:12241:13: warning: enumeration value ‘uninitialized’ not handled in switch [-Wswitch-enum]
             switch (last_token)
             ^~~~~~
../src/json.hpp:12241:13: warning: enumeration value ‘end_array’ not handled in switch [-Wswitch-enum]
../src/json.hpp:12241:13: warning: enumeration value ‘end_object’ not handled in switch [-Wswitch-enum]
../src/json.hpp:12241:13: warning: enumeration value ‘name_separator’ not handled in switch [-Wswitch-enum]
../src/json.hpp:12241:13: warning: enumeration value ‘value_separator’ not handled in switch [-Wswitch-enum]
../src/json.hpp:12241:13: warning: enumeration value ‘parse_error’ not handled in switch [-Wswitch-enum]
../src/json.hpp:12241:13: warning: enumeration value ‘end_of_input’ not handled in switch [-Wswitch-enum]
../src/json.hpp: In instantiation of ‘bool nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>::operator==(const nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>&) const [with U = const nlohmann::basic_json<>; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer]’:
../src/json.hpp:10033:34:   required from ‘bool nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>::operator!=(const nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>&) const [with U = const nlohmann::basic_json<>; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer]’
/Users/niels/Documents/projects/gcc/include/c++/7.0.1/bits/stl_algo.h:3883:22:   required from ‘_Funct std::for_each(_IIter, _IIter, _Funct) [with _IIter = nlohmann::basic_json<>::iter_impl<const nlohmann::basic_json<> >; _Funct = ____C_A_T_C_H____T_E_S_T____34()::<lambda(const json&)>]’
src/unit-algorithms.cpp:89:18:   required from here
../src/json.hpp:10008:13: warning: enumeration value ‘null’ not handled in switch [-Wswitch-enum]
             switch (m_object->m_type)
             ^~~~~~
../src/json.hpp:10008:13: warning: enumeration value ‘string’ not handled in switch [-Wswitch-enum]
../src/json.hpp:10008:13: warning: enumeration value ‘boolean’ not handled in switch [-Wswitch-enum]
../src/json.hpp:10008:13: warning: enumeration value ‘number_integer’ not handled in switch [-Wswitch-enum]
../src/json.hpp:10008:13: warning: enumeration value ‘number_unsigned’ not handled in switch [-Wswitch-enum]
../src/json.hpp:10008:13: warning: enumeration value ‘number_float’ not handled in switch [-Wswitch-enum]
../src/json.hpp:10008:13: warning: enumeration value ‘discarded’ not handled in switch [-Wswitch-enum]
../src/json.hpp: In instantiation of ‘nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>& nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>::operator--() [with U = nlohmann::basic_json<>; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer]’:
/Users/niels/Documents/projects/gcc/include/c++/7.0.1/bits/stl_algo.h:1136:38:   required from ‘void std::__reverse(_BidirectionalIterator, _BidirectionalIterator, std::bidirectional_iterator_tag) [with _BidirectionalIterator = nlohmann::basic_json<>::iter_impl<nlohmann::basic_json<> >]’
/Users/niels/Documents/projects/gcc/include/c++/7.0.1/bits/stl_algo.h:1186:21:   required from ‘void std::reverse(_BIter, _BIter) [with _BIter = nlohmann::basic_json<>::iter_impl<nlohmann::basic_json<> >]’
src/unit-algorithms.cpp:198:56:   required from here
../src/json.hpp:9970:13: warning: enumeration value ‘null’ not handled in switch [-Wswitch-enum]
             switch (m_object->m_type)
             ^~~~~~
../src/json.hpp:9970:13: warning: enumeration value ‘string’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9970:13: warning: enumeration value ‘boolean’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9970:13: warning: enumeration value ‘number_integer’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9970:13: warning: enumeration value ‘number_unsigned’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9970:13: warning: enumeration value ‘number_float’ not handled in switch [-Wswitch-enum]
../src/json.hpp:9970:13: warning: enumeration value ‘discarded’ not handled in switch [-Wswitch-enum]
../src/json.hpp: In instantiation of ‘nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>::difference_type nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>::operator-(const nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>&) const [with U = nlohmann::basic_json<>; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>::difference_type = long int]’:
/Users/niels/Documents/projects/gcc/include/c++/7.0.1/bits/stl_algo.h:1969:22:   required from ‘void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = nlohmann::basic_json<>::iter_impl<nlohmann::basic_json<> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
/Users/niels/Documents/projects/gcc/include/c++/7.0.1/bits/stl_algo.h:4822:18:   required from ‘void std::sort(_RAIter, _RAIter) [with _RAIter = nlohmann::basic_json<>::iter_impl<nlohmann::basic_json<> >]’
src/unit-algorithms.cpp:226:45:   required from here
../src/json.hpp:10166:13: warning: enumeration value ‘null’ not handled in switch [-Wswitch-enum]
             switch (m_object->m_type)
             ^~~~~~
../src/json.hpp:10166:13: warning: enumeration value ‘string’ not handled in switch [-Wswitch-enum]
../src/json.hpp:10166:13: warning: enumeration value ‘boolean’ not handled in switch [-Wswitch-enum]
../src/json.hpp:10166:13: warning: enumeration value ‘number_integer’ not handled in switch [-Wswitch-enum]
../src/json.hpp:10166:13: warning: enumeration value ‘number_unsigned’ not handled in switch [-Wswitch-enum]
../src/json.hpp:10166:13: warning: enumeration value ‘number_float’ not handled in switch [-Wswitch-enum]
../src/json.hpp:10166:13: warning: enumeration value ‘discarded’ not handled in switch [-Wswitch-enum]
../src/json.hpp: In instantiation of ‘bool nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>::operator<(const nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::iter_impl<U>&) const [with U = nlohmann::basic_json<>; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer]’:
/Users/niels/Documents/projects/gcc/include/c++/7.0.1/bits/stl_algo.h:1673:54:   required from ‘void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = nlohmann::basic_json<>::iter_impl<nlohmann::basic_json<> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
/Users/niels/Documents/projects/gcc/include/c++/7.0.1/bits/stl_algo.h:1933:25:   required from ‘void std::__partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = nlohmann::basic_json<>::iter_impl<nlohmann::basic_json<> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
/Users/niels/Documents/projects/gcc/include/c++/7.0.1/bits/stl_algo.h:4675:26:   required from ‘void std::partial_sort(_RAIter, _RAIter, _RAIter) [with _RAIter = nlohmann::basic_json<>::iter_impl<nlohmann::basic_json<> >]’
src/unit-algorithms.cpp:252:64:   required from here
../src/json.hpp:10050:13: warning: enumeration value ‘null’ not handled in switch [-Wswitch-enum]
             switch (m_object->m_type)
             ^~~~~~
../src/json.hpp:10050:13: warning: enumeration value ‘string’ not handled in switch [-Wswitch-enum]
../src/json.hpp:10050:13: warning: enumeration value ‘boolean’ not handled in switch [-Wswitch-enum]
../src/json.hpp:10050:13: warning: enumeration value ‘number_integer’ not handled in switch [-Wswitch-enum]
../src/json.hpp:10050:13: warning: enumeration value ‘number_unsigned’ not handled in switch [-Wswitch-enum]
../src/json.hpp:10050:13: warning: enumeration value ‘number_float’ not handled in switch [-Wswitch-enum]
../src/json.hpp:10050:13: warning: enumeration value ‘discarded’ not handled in switch [-Wswitch-enum]
../src/json.hpp: In instantiation of ‘bool nlohmann::operator<(nlohmann::basic_json<>::const_reference, nlohmann::basic_json<>::const_reference)’:
/Users/niels/Documents/projects/gcc/include/c++/7.0.1/bits/predefined_ops.h:43:23:   required from ‘bool __gnu_cxx::__ops::_Iter_less_iter::operator()(_Iterator1, _Iterator2) const [with _Iterator1 = nlohmann::basic_json<>::iter_impl<nlohmann::basic_json<> >; _Iterator2 = nlohmann::basic_json<>::iter_impl<nlohmann::basic_json<> >]’
/Users/niels/Documents/projects/gcc/include/c++/7.0.1/bits/stl_algo.h:4866:14:   required from ‘_OutputIterator std::__merge(_InputIterator1, _InputIterator1, _InputIterator2, _InputIterator2, _OutputIterator, _Compare) [with _InputIterator1 = nlohmann::basic_json<>::iter_impl<nlohmann::basic_json<> >; _InputIterator2 = nlohmann::basic_json<>::iter_impl<nlohmann::basic_json<> >; _OutputIterator = std::back_insert_iterator<nlohmann::basic_json<> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]’
/Users/niels/Documents/projects/gcc/include/c++/7.0.1/bits/stl_algo.h:4923:37:   required from ‘_OIter std::merge(_IIter1, _IIter1, _IIter2, _IIter2, _OIter) [with _IIter1 = nlohmann::basic_json<>::iter_impl<nlohmann::basic_json<> >; _IIter2 = nlohmann::basic_json<>::iter_impl<nlohmann::basic_json<> >; _OIter = std::back_insert_iterator<nlohmann::basic_json<> >]’
src/unit-algorithms.cpp:266:94:   required from here
../src/json.hpp:6327:13: warning: enumeration value ‘discarded’ not handled in switch [-Wswitch-enum]
             switch (lhs_type)
             ^~~~~~
../src/json.hpp: In instantiation of ‘void nlohmann::detail::from_json(const BasicJsonType&, ArithmeticType&) [with BasicJsonType = nlohmann::basic_json<>; ArithmeticType = int; typename std::enable_if<((((std::is_arithmetic<ArithmeticType>::value && (! std::is_same<ArithmeticType, typename BasicJsonType::number_unsigned_t>::value)) && (! std::is_same<ArithmeticType, typename BasicJsonType::number_integer_t>::value)) && (! std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value)) && (! std::is_same<T, typename BasicJsonType::boolean_t>::value)), int>::type <anonymous> = 0]’:
../src/json.hpp:1113:25:   required from ‘decltype ((nlohmann::detail::from_json(j, val), void())) nlohmann::detail::from_json_fn::call(const BasicJsonType&, T&, nlohmann::detail::priority_tag<1>) const [with BasicJsonType = nlohmann::basic_json<>; T = int; decltype ((nlohmann::detail::from_json(j, val), void())) = void]’
../src/json.hpp:1128:47:   required from ‘void nlohmann::detail::from_json_fn::operator()(const BasicJsonType&, T&) const [with BasicJsonType = nlohmann::basic_json<>; T = int]’
../src/json.hpp:1175:30:   required from ‘static void nlohmann::adl_serializer< <template-parameter-1-1>, <template-parameter-1-2> >::from_json(BasicJsonType&&, ValueType&) [with BasicJsonType = const nlohmann::basic_json<>&; ValueType = int; <template-parameter-1-1> = int; <template-parameter-1-2> = void]’
../src/json.hpp:3485:45:   required from ‘ValueType nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::get() const [with ValueTypeCV = int; ValueType = int; typename std::enable_if<(((! std::is_same<nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>, ValueType>::value) && nlohmann::detail::has_from_json<nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>, ValueType>::value) && (! nlohmann::detail::has_non_default_from_json<nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>, ValueType>::value)), int>::type <anonymous> = 0; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer]’
src/unit-algorithms.cpp:59:13:   required from here
../src/json.hpp:1050:5: warning: enumeration value ‘null’ not handled in switch [-Wswitch-enum]
     switch (static_cast<value_t>(j))
     ^~~~~~
../src/json.hpp:1050:5: warning: enumeration value ‘object’ not handled in switch [-Wswitch-enum]
../src/json.hpp:1050:5: warning: enumeration value ‘array’ not handled in switch [-Wswitch-enum]
../src/json.hpp:1050:5: warning: enumeration value ‘string’ not handled in switch [-Wswitch-enum]
../src/json.hpp:1050:5: warning: enumeration value ‘discarded’ not handled in switch [-Wswitch-enum]
../src/json.hpp: In instantiation of ‘nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::basic_json(const nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>&) [with ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer]’:
/Users/niels/Documents/projects/gcc/include/c++/7.0.1/bits/stl_algobase.h:685:11:   required from ‘typename __gnu_cxx::__enable_if<(! std::__is_scalar<_Tp>::__value), void>::__type std::__fill_a(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = nlohmann::basic_json<>*; _Tp = nlohmann::basic_json<>; typename __gnu_cxx::__enable_if<(! std::__is_scalar<_Tp>::__value), void>::__type = void]’
/Users/niels/Documents/projects/gcc/include/c++/7.0.1/bits/stl_algobase.h:731:20:   required from ‘void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = nlohmann::basic_json<>*; _Tp = nlohmann::basic_json<>]’
/Users/niels/Documents/projects/gcc/include/c++/7.0.1/bits/vector.tcc:483:14:   required from ‘void std::vector<_Tp, _Alloc>::_M_fill_insert(std::vector<_Tp, _Alloc>::iterator, std::vector<_Tp, _Alloc>::size_type, const value_type&) [with _Tp = nlohmann::basic_json<>; _Alloc = std::allocator<nlohmann::basic_json<> >; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<nlohmann::basic_json<>*, std::vector<nlohmann::basic_json<>, std::allocator<nlohmann::basic_json<> > > >; typename std::_Vector_base<_Tp, _Alloc>::pointer = nlohmann::basic_json<>*; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = nlohmann::basic_json<>]’
/Users/niels/Documents/projects/gcc/include/c++/7.0.1/bits/stl_vector.h:1087:16:   required from ‘std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, std::vector<_Tp, _Alloc>::size_type, const value_type&) [with _Tp = nlohmann::basic_json<>; _Alloc = std::allocator<nlohmann::basic_json<> >; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<nlohmann::basic_json<>*, std::vector<nlohmann::basic_json<>, std::allocator<nlohmann::basic_json<> > > >; typename std::_Vector_base<_Tp, _Alloc>::pointer = nlohmann::basic_json<>*; std::vector<_Tp, _Alloc>::const_iterator = __gnu_cxx::__normal_iterator<const nlohmann::basic_json<>*, std::vector<nlohmann::basic_json<>, std::allocator<nlohmann::basic_json<> > > >; typename __gnu_cxx::__alloc_traits<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type>::const_pointer = const nlohmann::basic_json<>*; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = nlohmann::basic_json<>]’
../src/json.hpp:3998:17:   required from ‘nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::value_type& nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::operator[](nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::size_type) [with ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long long int; NumberUnsignedType = long long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::reference = nlohmann::basic_json<>&; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::value_type = nlohmann::basic_json<>; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::size_type = long unsigned int]’
src/unit-algorithms.cpp:106:17:   required from here
../src/json.hpp:2676:9: warning: enumeration value ‘null’ not handled in switch [-Wswitch-enum]
         switch (m_type)
         ^~~~~~
../src/json.hpp:2676:9: warning: enumeration value ‘discarded’ not handled in switch [-Wswitch-enum]

@cmaglie
Copy link
Author

cmaglie commented Apr 15, 2017

It seems that the compiler emits the warning only when a templated function is actually used. I'm currently using the library just to output a bunch of JSON data and when I compile my program it doesn't emit any warning (because I fixed only the ones I'm interested in).

Even more strange is that if I try to compile the following empty test program:

#include "src/json.hpp"

int main() {
  return 0;
}

it emits one warning:

~/Workspace/json$ g++ test.cpp -o xxx -Wswitch-enum -std=c++11
In file included from test.cpp:1:0:
src/json.hpp: In instantiation of ‘nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer> nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::parser::parse_internal(bool) [with ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer]’:
src/json.hpp:11672:47:   required from ‘nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer> nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::parser::parse() [with ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer]’
src/json.hpp:7403:37:   required from ‘static nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer> nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::parse(IteratorType, IteratorType, nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::parser_callback_t) [with IteratorType = const char*; typename std::enable_if<std::is_base_of<std::random_access_iterator_tag, typename std::iterator_traits<_InputIterator>::iterator_category>::value, int>::type <anonymous> = 0; ObjectType = std::map; ArrayType = std::vector; StringType = std::__cxx11::basic_string<char>; BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer; nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::parser_callback_t = std::function<bool(int, nlohmann::basic_json<>::parse_event_t, nlohmann::basic_json<>&)>]’
src/json.hpp:13400:42:   required from here
src/json.hpp:11693:13: warning: enumeration value ‘uninitialized’ not handled in switch [-Wswitch-enum]
             switch (last_token)
             ^~~~~~
src/json.hpp:11693:13: warning: enumeration value ‘end_array’ not handled in switch [-Wswitch-enum]
src/json.hpp:11693:13: warning: enumeration value ‘end_object’ not handled in switch [-Wswitch-enum]
src/json.hpp:11693:13: warning: enumeration value ‘name_separator’ not handled in switch [-Wswitch-enum]
src/json.hpp:11693:13: warning: enumeration value ‘value_separator’ not handled in switch [-Wswitch-enum]
src/json.hpp:11693:13: warning: enumeration value ‘parse_error’ not handled in switch [-Wswitch-enum]
src/json.hpp:11693:13: warning: enumeration value ‘end_of_input’ not handled in switch [-Wswitch-enum]

(on line 11693, that is not patched in this PR), even if I expect to not emit any warning...

Anyway: there are some other switch/case that are "affected" by these warnings and some of them requires a bit of restructuring of the code to be fixed properly... but unfortunately I can't spend more time on this issue so I'm not going to fix them.

You can merge this patch as is, to fix at least the 4 warnings and leave the remaining for later... or just reject the PR, up to you :-).

@gregmarr
Copy link
Contributor

-Wswitch-enum warns even with a default, and removing the default adds a warning when using -Wswitch-default.

https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html

-Wswitch
Warn whenever a switch statement has an index of enumerated type and lacks a case for one or more of the named codes of that enumeration. (The presence of a default label prevents this warning.) case labels outside the enumeration range also provoke warnings when this option is used (even if there is a default label). This warning is enabled by -Wall.

-Wswitch-default
Warn whenever a switch statement does not have a default case.

-Wswitch-enum
Warn whenever a switch statement has an index of enumerated type and lacks a case for one or more of the named codes of that enumeration. case labels outside the enumeration range also provoke warnings when this option is used. The only difference between -Wswitch and this option is that this option gives a warning about an omitted enumeration code even if there is a default label.

@cmaglie
Copy link
Author

cmaglie commented Apr 15, 2017

The output from gcc is different from clang here.

Consider this:

enum Enum {
    ValA, ValB
};

int main() {
    Enum x = ValA; 

    switch (x) { // Line 8
    	case ValA:
    	case ValB:
    		break;
    };

    switch (x) {
    	case ValA:
    	case ValB:
    	default: // Line 17
    		break;
    };

    int y = 0;
    switch (y) { // Line 22
    	case 10:
    	case 20:
    		break;
    };
    return 0;
}

and the following calls to compilers:

$ g++ test.cpp -c -std=c++11 -Wswitch -Wswitch-default -Wswitch-enum
test.cpp: In function ‘int main()’:
test.cpp:8:12: warning: switch missing default case [-Wswitch-default]
     switch (x) { // Line 8
            ^
test.cpp:22:12: warning: switch missing default case [-Wswitch-default]
     switch (y) { // Line 22
            ^

$ clang++ test.cpp -c -std=c++11 -Wswitch -Wswitch-default -Wswitch-enum

$ clang++ test.cpp -c -std=c++11 -Wswitch-default 

$ clang++ test.cpp -c -std=c++11 -Weverything
test.cpp:17:6: warning: default label in switch which covers all enumeration values [-Wcovered-switch-default]
        default: // Line 17
        ^
1 warning generated.

$ g++ test.cpp -c -std=c++11 -Wall -Wextra -Wpedantic

$ clang++ test.cpp -c -std=c++11 -Wall -Wextra -Wpedantic

So it seems that in clang -Wswitch-default acts as a no-op, TBH I prefer clang's implementation where the check for the default is made on enum values.

IMHO, to be really useful, gcc's -Wswitch-default check should be implemented on non-enum values only as switching over enums is better handled with -Wswitch-enum.

@gregmarr
Copy link
Contributor

gregmarr commented Apr 15, 2017

Yes, the switch on enum diagnostics are different between gcc and clang. They apparently have different philosophies about switching on an enum. Clang thinks that if you cover all the explicit values, then you should ignore anything else. Gcc thinks that you should have a default case to handle anything not specified. So it is impossible to make code which is clean with both -Wcovered-switch-default and -Wswitch-default -Wswitch-enum at the same time.

https://clang.llvm.org/docs/DiagnosticsReference.html

-Wcovered-switch-default

Diagnostic text:

warning: default label in switch which covers all enumeration values

-Wswitch-default

This diagnostic flag exists for GCC compatibility, and has no effect in Clang.

@nlohmann
Copy link
Owner

Thanks for the effort, but I decided not to merge this. As @gregmarr described, you can't have it all ways.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants