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

C++ checked switch using fall through #8155

Conversation

roberth
Copy link
Member

@roberth roberth commented Apr 3, 2023

Motivation

This approach catches programming errors, but relies on contributors to use the right pattern, which is not obvious. We may consider -Werror=switch-enum instead, which requires us to rewrite some switches to ifs or to enumerate more cases.

To be discussed.

Context

Will prevent bugs like #8119
Complements

Checklist for maintainers

Maintainers: tick if completed or explain if not relevant

  • agreed on idea
  • agreed on implementation strategy
  • tests, as appropriate
    • functional tests - tests/**.sh
    • unit tests - src/*/tests
    • integration tests - tests/nixos/*
  • documentation in the manual
  • documentation in the internal API docs
  • code and comments are self-explanatory
  • commit message explains why the change was made
  • new feature or incompatible change: updated release notes

Priorities

Add 👍 to pull requests you find important.

@roberth roberth requested a review from edolstra as a code owner April 3, 2023 14:05
@github-actions github-actions bot added the with-tests Issues related to testing. PRs with tests have some priority label Apr 3, 2023
This catches bugs like NixOS#8119 early.
It is not the prettiest solution though, but one that can be applied
gradually.
@roberth roberth force-pushed the c++-checked-switch-using-fall-through branch from 47fd6ad to 4bc75ce Compare April 3, 2023 14:07
@github-actions github-actions bot removed the with-tests Issues related to testing. PRs with tests have some priority label Apr 3, 2023
@roberth
Copy link
Member Author

roberth commented Apr 3, 2023

Not good enough -Werror=switch-enum finds more bugs...

@roberth roberth closed this Apr 3, 2023
@roberth roberth mentioned this pull request Apr 3, 2023
8 tasks
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.

1 participant