Archived issue #0025616
Avoid Classes using "new" to allocate Instances but not defining a copy Constructor
Description
A copy constructor is highly recommended to avoid surprises when an object is initialized using an object of the same type. If an object manages the allocation and deallocation of an object on the heap (the managing object has a pointer to the object to be created by the class' constructor), only the value of the pointer will be copied. This can lead to two invocations of the destructor for the same object (on the heap), probably resulting in a run-time error.
Steps to reproduce
not applicable
Additional information
The following classes use “new” function without Handles:
- Select3D_PointData
- BSB_T3Bits
- IntPatch_InfoPD
- LDOM_StringElem
- BinomAllocator
- ProjLib_OnSurface
- Standard_MMgrFactory
Objects of these classes must not be copied. It is necessary to add empty copy constructor and assignment operator to protected/private section.
- Select3D_PointData
- BSB_T3Bits
- IntPatch_InfoPD
- LDOM_StringElem
- BinomAllocator
- ProjLib_OnSurface
- Standard_MMgrFactory
Objects of these classes must not be copied. It is necessary to add empty copy constructor and assignment operator to protected/private section.
Public activity
7 archived notes
Participants are labeled by their role within this record.
Branch [archived branch] has been created by Author.
[revision removed]
Detailed log of new commits:
Author: Author
Date: Wed Dec 17 12:37:06 2014 +0300
0025616: Avoid Classes using "new" to allocate Instances but not defining a copy Constructor
The empty copy constructor, assignemnts operator, default constructors added to the following classes:
[revision removed]
Detailed log of new commits:
Author: Author
Date: Wed Dec 17 12:37:06 2014 +0300
0025616: Avoid Classes using "new" to allocate Instances but not defining a copy Constructor
The empty copy constructor, assignemnts operator, default constructors added to the following classes:
Branch [archived branch] has been updated by Author.
[revision removed]
Detailed log of new commits:
Author: Author
Date: Fri Dec 26 15:34:13 2014 +0300
0025616: Avoid Classes using "new" to allocate Instances but not defining a copy Constructor
Useless declaration of default constructor have been deleted.
[revision removed]
Detailed log of new commits:
Author: Author
Date: Fri Dec 26 15:34:13 2014 +0300
0025616: Avoid Classes using "new" to allocate Instances but not defining a copy Constructor
Useless declaration of default constructor have been deleted.
No remarks, please test
Branch [archived branch] has been updated forcibly by Participant.
[revision removed]
[revision removed]
Branch [archived branch] has been rebased on the current master
Dear Commenter 1,
Branch CR25616 from occt git-repository (and master from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested.
[revision removed]
Number of compiler warnings:
occt component:
Linux: 18 (18 on master)
Windows: 0 (0 on master)
products component :
Linux: 11 (11 on master)
Windows: 1 (1 on master)
Regressions/Differences:
Not detected
Testing cases:
Not needed
Testing on Linux:
Total MEMORY difference: 369216928 / 369132708
Total CPU difference: 50656.09000000034 / 46134.12000000006
Testing on Windows:
Total MEMORY difference: 276574444 / 276918412
Total CPU difference: 39410.21875 / 38326.15625
Branch CR25616 from occt git-repository (and master from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested.
[revision removed]
Number of compiler warnings:
occt component:
Linux: 18 (18 on master)
Windows: 0 (0 on master)
products component :
Linux: 11 (11 on master)
Windows: 1 (1 on master)
Regressions/Differences:
Not detected
Testing cases:
Not needed
Testing on Linux:
Total MEMORY difference: 369216928 / 369132708
Total CPU difference: 50656.09000000034 / 46134.12000000006
Testing on Windows:
Total MEMORY difference: 276574444 / 276918412
Total CPU difference: 39410.21875 / 38326.15625
Branch [archived branch] has been deleted by Participant.
[revision removed]
[revision removed]
Related records