[SERVER-55204] Opt in to -Wimplicit-fallthrough in src/mongo Created: 15/Mar/21  Updated: 29/Oct/23  Resolved: 18/Apr/22

Status: Closed
Project: Core Server
Component/s: Build, Internal Code
Affects Version/s: None
Fix Version/s: 6.1.0-rc0

Type: Improvement Priority: Major - P3
Reporter: Mathias Stearn Assignee: Andrew Morrow (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Problem/Incident
Related
related to SERVER-75617 Make case fallthroughs explicit Closed
is related to SERVER-65927 Annotate switch fallthrough in bson_v... Closed
Backwards Compatibility: Fully Compatible
Sprint: Dev Platform 2022-04-18
Participants:
Linked BF Score: 65

 Description   

This is a very easy bug to accidentally type, and can be hard to notice in code review. There are only a handful of current violations. I haven't checked if any are bugs, but even if they aren't, it seems like it would be easier for the reader to have an explicit [[fallthrough]] annotation.



 Comments   
Comment by Githook User [ 26/May/22 ]

Author:

{'name': 'Andrew Morrow', 'email': 'acm@mongodb.com', 'username': 'acmorrow'}

Message: SERVER-60440 Upgrade boost to 1.79.0

Comment by Iryna Zhuravlova [ 18/Apr/22 ]

Drew will announce it to the db-contribs

Comment by Githook User [ 18/Apr/22 ]

Author:

{'name': 'Andrew Morrow', 'email': 'acm@mongodb.com', 'username': 'acmorrow'}

Message: SERVER-55204 Error on fallthrough unless the attribute is used
Branch: master
https://github.com/mongodb/mongo/commit/c9c6b145e47ce97f077bc1af3d266db64e8afb65

Comment by Githook User [ 18/Apr/22 ]

Author:

{'name': 'Andrew Morrow', 'email': 'acm@mongodb.com', 'username': 'acmorrow'}

Message: SERVER-55204 Apply fallthrough attribute where required
Branch: master
https://github.com/10gen/mongo-enterprise-modules/commit/81566c862b56d89d57cc668a4a06cb53cb0441ba

Comment by Blake Oler [ 28/Mar/22 ]

This seems like a scons change – if there are any ServiceArch related implicit fallthroughs our team needs to look at, feel free to reach out to the Service Architecture channel. Reassigning to backlog-server-devplatform

Comment by Mathias Stearn [ 18/Mar/22 ]

lauren.lewis, what sort of additional information are you looking for? This ticket is suggesting that we enable a compiler flag that can prevent easily overlooked and annoying to debug bugs. Is there some clarification needed?

Comment by Lauren Lewis (Inactive) [ 18/Mar/22 ]

We haven’t heard back from you for some time, so we're going to close this ticket. If this is still an issue for you, please provide additional information and we will reopen the ticket.

Comment by Mathias Stearn [ 15/Mar/21 ]

May want to only do this on GCC since gcc disables the warning if it sees a // fallthrough comment (unfortunately it has to be after closing brace due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81230), while clang will warn unless it sees an actual [[fallthrough]] (or clang-specific equivalent) even if there is a comment. I've only confirmed that there is a manageable amount of warnings (with none in third-party headers) with GCC, so it is possible that it will be still be impractical to use this with clang.

Generated at Thu Feb 08 05:35:48 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.