[SERVER-29601] Add -Wshadow to compilation Created: 13/Jun/17  Updated: 02/Feb/24

Status: Open
Project: Core Server
Component/s: Build
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Eric Milkie Assignee: Unassigned
Resolution: Unresolved Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Assigned Teams:
Build
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Platforms 2017-07-10
Participants:

 Description   

-Wshadow is supported by both Clang and GCC, and seems like a reasonable warning to add. AFAIK there are only a few violations of this warning today – which should be easily fixable.

This could be done as part of a larger effort to evaluate newly added warnings to recent versions of clang/gcc.



 Comments   
Comment by Githook User [ 11/Nov/22 ]

Author:

{'name': 'Juan Gu', 'email': 'juan.gu@mongodb.com', 'username': 'juangugit'}

Message: SERVER-29601 Add -Wshadow to compilation - part1
Branch: master
https://github.com/mongodb/mongo/commit/fffe2cb03d8f3a826f7039614ee1c12d88917440

Comment by Andrew Morrow (Inactive) [ 05/May/21 ]

It sounds like a perfect type of thing for a fixit day. Find all the instances somehow, make a spreadsheet, get 20 volunteers, everyone fixes 15. Done.

Comment by Billy Donahue [ 05/May/21 ]


Doing a simple blind rename would forfeit the 300+ opportunities to catch shadowing bugs. We'd be just affirming the compiled code as correct without really looking to see if it is. I think we'd have to look at each one to see if it was intentional to fix the warnings properly. Shouldn't take that long to do each one, but I think it's a problem that needs eyeballs not robots. Okay maybe a little of both.

Comment by Andrew Morrow (Inactive) [ 04/Nov/19 ]

I'm adding this to the "coding style enforcement" epic because I think the way to approach this is to use clang-tidy and a fixit to address the existing shadowing issues, which would then allow us to turn on the flag.

Comment by Eric Milkie [ 12/Apr/19 ]

Rather than making separate SERVER tickets for each of the shadow problems in our code that Coverity is flagging, I'm going to mark all of them "ignore" for now, so that we can see the more critical problems in the Coverity report. If in the future we decide we want to add this warning, we can revisit the list that Coverity has flagged.

Comment by Eric Milkie [ 04/Oct/17 ]

A recommended list for other warnings we might consider turning on:
https://kristerw.blogspot.com/2017/09/useful-gcc-warning-options-not-enabled.html
Many of these are detected by Coverity but it would be better to catch them at compile time.

Comment by Ben Shteinfeld [ 22/Jun/17 ]

There 293 violations of the `-Wshadow` compile flag in the codebase. Of these 18 are in src/third_party, the rest are in src/mongo. Per discussion with spencer.jackson and mira.carey@mongodb.com, these violations should have a suffix added to them using rtags.

Generated at Thu Feb 08 04:21:19 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.