-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
Use C++17 [[fallthrough]] in transaction_test.cc #11663
Conversation
@jaykorean has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@@ -4990,7 +4990,7 @@ TEST_P(TransactionTest, DeleteRangeSupportTest) { | |||
} | |||
break; | |||
case WRITE_PREPARED: | |||
// Intentional fall-through |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a macro for this too: https://github.com/facebook/rocksdb/blob/main/port/lang.h#L10 how about using that macro for now to be consistent with other code and migrate the macro later.
@jaykorean has updated the pull request. You must reimport the pull request before landing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for the PR!
@jaykorean has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@jaykorean merged this pull request in 9a2a6db. |
Summary
(Copied from https://www.internalfb.com/diff/D46606060)
This diff makes its files safe for use with -Wimplicit-fallthrough. Now that we're using C+20 there's no reason not to use this C++17 feature to make our code safer.
It's currently possible to write code like this:
But that's scary because we don't know whether the fallthrough from case 1 was intentional or not.
The -Wimplicit-fallthrough flag will make this an error. The solution is to either fix the bug by inserting break or indicating intention by using [[fallthrough]]; (from C++17).
Test Plan
Existing tests