boostorg / property_tree

Boost.org property_tree module
http://boost.org/libs/property_tree
55 stars 93 forks source link

Fix Wcovered-switch-default warning #29

Closed garyfurnish closed 11 months ago

garyfurnish commented 7 years ago

On clang with -Wcovered-switch-default this fixes the following error: /mnt/fscratch0/pub/dependencies/boost/boost/property_tree/json_parser/detail/standard_callbacks.hpp:130:6: error: default label in switch which covers all enumeration values [-Werror,-Wcovered-switch-default] default:

Essentially default is unnecessary and may prevent detection of future bugs by allowing catching future added enums. This moves the Assert to the bottom of the function where it theoretically is dead code as the enum is fully covered by returns.

pdimov commented 11 months ago

Closing/reopening to retrigger CI.

pdimov commented 11 months ago

Since BOOST_ASSERT disappears in release builds, this change results in a "not all control paths return a value" warning.

ashtum commented 11 months ago

Since BOOST_ASSERT disappears in release builds, this change results in a "not all control paths return a value" warning.

This should be the case for the current code as well, because it relies on BOOST_ASSERT in these two cases:

            case object:
            default:
                BOOST_ASSERT(false); // must start with string, i.e. call new_value
pdimov commented 11 months ago

It's not, as the CI results show. The code just falls through to the next case.

This PR can probably be fixed to be warning-free by adding BOOST_UNREACHABLE_RETURN(root) at the end.