Skip to content

Silence [[fallthrough]] warnings#3162

Merged
StephanTLavavej merged 4 commits into
microsoft:mainfrom
StephanTLavavej:fallthrough
Oct 24, 2022
Merged

Silence [[fallthrough]] warnings#3162
StephanTLavavej merged 4 commits into
microsoft:mainfrom
StephanTLavavej:fallthrough

Conversation

@StephanTLavavej
Copy link
Copy Markdown
Member

MSVC has implemented a new off-by-default "warning C5262: implicit fall-through occurs here; are you missing a break statement? Use [[fallthrough]] when a break statement is intentionally omitted between cases". While we don't attempt to be /Wall clean in general, this warning is high value (capable of detecting bugs in product code!) and easy to avoid.

Much of our C++17-and-later code is already using the [[fallthrough]] attribute. For our older code, I'm introducing a _FALLTHROUGH macro.

In VSO_0226079_mutex, we can simply avoid fallthrough by repeating a bit of code.

Adding /w15262 to tests/universal_prefix.lst provides comprehensive test coverage.

Finally, we need to silence fallthrough warnings in variant after _STL_UNREACHABLE - these are the only occurrences that weren't already commented.

Reported as DevCom-10163250 and internal VSO-1644941 / AB#1644941 .

warning C5262: implicit fall-through occurs here; are you missing a break statement? Use [[fallthrough]] when a break statement is intentionally omitted between cases
@StephanTLavavej StephanTLavavej added the bug Something isn't working label Oct 19, 2022
@StephanTLavavej StephanTLavavej requested a review from a team as a code owner October 19, 2022 08:52
Comment thread stl/inc/variant
@StephanTLavavej StephanTLavavej self-assigned this Oct 21, 2022
@StephanTLavavej
Copy link
Copy Markdown
Member Author

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej StephanTLavavej merged commit fb386c0 into microsoft:main Oct 24, 2022
@StephanTLavavej StephanTLavavej deleted the fallthrough branch October 24, 2022 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants