Open
Bug 1229476
Opened 9 years ago
Updated 2 years ago
Give a warning when a copy-constructor/assignment operator reimplements the default ones.
Categories
(Developer Infrastructure :: Source Code Analysis, defect)
Developer Infrastructure
Source Code Analysis
Tracking
(Not tracked)
NEW
People
(Reporter: jrmuizel, Unassigned)
References
Details
Code should either use '= default' or just use the default one. Manually coding it is prone to bugs.
Comment 1•9 years ago
|
||
What would you want to catch for a re-implementation? Initialization of every element to the element from the other type? Should a sequence of assignments in the body be handled as well? How about the ordering? Here's a few of my immediate thoughts on this: /* Obviously (I think) this should be caught */ class F { int i; public: F(const F& o) : i(o.i) {} // Catch this }; /* Some examples which could technically change if the default is used... */ class F { int i; public: F(const F& o) { i = o.i; // Catch this too? Technically uses operator= rather than the copy constructor, so it could be different... } }; class F { A a; B b; public: F(const F& o) { b = o.b; // This not only uses operator=, but also initializes in a different order, should this be caught? a = o.a; } }; I'm sure that there are other things which I didn't immediately think of, but these are questions which I think should be answered.
Reporter | ||
Comment 2•9 years ago
|
||
I think the answers to these questions might depend on what kind of code ends up giving warnings. The code that I saw that inspired this bug was using the assignment syntax, so my gut would be to catch that. I think we may need to iterate on the semantics though.
Updated•6 years ago
|
Product: Core → Firefox Build System
Updated•2 years ago
|
Product: Firefox Build System → Developer Infrastructure
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•