Copy constructor not called in initialization list
Copy constructor does not call copy constructors of some members or base classes
Description
This defect occurs when the copy constructor of a class does not call the copy constructor of the following in its initialization list:
One or more of its members.
Its base classes when applicable.
The defect occurs even when a base class constructor is called instead of the base class copy constructor.
Risk
The calls to the copy constructors can be done only from the initialization list. If the calls are missing, it is possible that an object is only partially copied.
If the copy constructor of a member is not called, it is possible that the member is not copied.
If the copy constructor of a base class is not called, it is possible that the base class members are not copied.
Fix
If you want your copy constructor to perform a complete copy, call the copy constructor of all members and all base classes in its initialization list.
Examples
Result Information
Group: Object oriented |
Language: C++ |
Default: On for handwritten code, off for generated code |
Command-Line Syntax: MISSING_COPY_CTOR_CALL |
Impact: High |
Version History
Introduced in R2015b
See Also
Find defects (-checkers)
| Base class assignment operator not called
Topics
- Interpret Bug Finder Results in Polyspace Desktop User Interface
- Interpret Bug Finder Results in Polyspace Access Web Interface (Polyspace Access)
- Address Results in Polyspace User Interface Through Bug Fixes or Justifications
- Address Results in Polyspace Access Through Bug Fixes or Justifications (Polyspace Access)