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 Wcovered-switch-default warning #29

Merged
merged 1 commit into from
Nov 24, 2023

Conversation

garyfurnish
Copy link
Contributor

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.

@ashtum ashtum closed this Nov 21, 2023
@ashtum ashtum reopened this Nov 21, 2023
@pdimov pdimov closed this Nov 21, 2023
@pdimov pdimov reopened this Nov 21, 2023
@pdimov
Copy link
Member

pdimov commented Nov 21, 2023

Closing/reopening to retrigger CI.

@pdimov
Copy link
Member

pdimov commented Nov 21, 2023

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

@ashtum
Copy link
Collaborator

ashtum commented Nov 22, 2023

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
Copy link
Member

pdimov commented Nov 22, 2023

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.

@ashtum ashtum closed this Nov 24, 2023
@ashtum ashtum reopened this Nov 24, 2023
@pdimov pdimov merged commit 90786bb into boostorg:develop Nov 24, 2023
134 of 163 checks passed
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.

3 participants