[SERVER-68822] Coverity analysis defect 122804: AUTO_CAUSES_COPY Created: 15/Aug/22 Updated: 14/Jul/23 Resolved: 14/Jul/23 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Coverity Collector User | Assignee: | Jennifer Wang (Inactive) |
| Resolution: | Won't Do | Votes: | 0 |
| Labels: | coverity, neweng | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Assigned Teams: |
Service Arch
|
| Operating System: | ALL |
| Sprint: | Service Arch 2023-07-10, Service Arch 2023-07-24 |
| Participants: |
| Description |
|
AUTO_CAUSES_COPY Unnecessary object copies can affect performance. Using the auto keyword without an & causes a copy. |
| Comments |
| Comment by Eric Milkie [ 14/Jul/23 ] | |||
|
kyle.suarez@mongodb.com is the new caretaker for Coverity. | |||
| Comment by Jennifer Wang (Inactive) [ 14/Jul/23 ] | |||
|
This is not a real issue. We'd prefer to silence Coverity rather than make unnecessary changes to avoid the false positive. milkie@mongodb.com Is there a way to silence Coverity? | |||
| Comment by Billy Donahue [ 13/Jul/23 ] | |||
|
False positive. Adding reference quals to this `auto` has no effect, as the initializer expression is a prvalue.
The compiler will do the right thing to produce a prvalue inside each branch of the conditional. There is no additional overhead in initializing the local variable by move construction from that prvalue. https://gcc.godbolt.org/z/xbsqTc6qf Coverity is flat-out incorrect that auto variables "cause" object copies. | |||
| Comment by Blake Oler [ 22/Aug/22 ] | |||
|
If this was in a non-legacy part of the command path, I would treat this with higher priority. |