View Issue Details

IDProjectCategoryView StatusLast Update
0025622Open CASCADEOCCT:Codingpublic2016-01-08 20:02
ReporteraznAssigned Tobugmaster  
PrioritynormalSeverityminor 
Status closedResolutionfixed 
Product Version6.7.0 
Target Version6.9.0Fixed in Version6.9.0 
Summary0025622: CAST analysis: Avoid invocation of virtual Methods of the declared Class in a Constructor or Destructor
DescriptionInvoking virtual Methods in a constructor always invokes the Method for the current Class, or its base, even when the constructor is invoked as part of the construction of a derived Class. This also applies to virtual Methods called in a Destructor.
Steps To Reproducenot applicable
Additional information
and documentation updates
This problem is connected to cdl-mechanism. Virtual methods Delete() or Destroy() are called in Destructors of following classes:

- Adaptor2d_Curve2d
- Adaptor3d_Curve
- Adaptor3d_Surface
- AppBlend_Approx
- AppCont_Function
- AppParCurves_MultiCurve
- AppParCurves_MultiPoint
- ApproxInt_SvSurfaces
- BRepPrim_OneAxis
- BRepSweep_NumLinearRegularSweep
- CDM_Document (Destroy method)
- DBC_BaseArray
- GeomFill_Profiler
- Graphic3d_DataStructureManager (Destroy method)
- HatchGen_PointOnHatching
- Interface_CopyTool (Destroy method)
- math_BFGS
- math_FunctionSet
- math_FunctionSetRoot
- math_FunctionWithDerivative
- math_MultipleVarFunctionWithGradient
- OSD_Chronometer (Destroy method)
- ProjLib_Projector
- PrsMgr_Presentation (Destroy method)

It is necessary to move functionality of these methods in Destructors and remove them.

See: 0025619
TagsNo tags attached.
Test case numberNot needed

Relationships

has duplicate 0025577 closedazn Avoid invocation of virtual Methods of the declared Class in a Constructor or Destructor 
related to 0025720 closedbugmaster Incorrect code of math classes can lead to unpredicted behavior of algorithms 
related to 0025725 newabv Avoid invocation of virtual methods in constructors and destructors 
related to 0027067 closedabv Avoid use of virtual methods for implementation of destructors in legacy classes 

Activities

git

2014-12-18 10:28

administrator   ~0035469

Branch CR25622 has been created by azn.

SHA-1: c94fb0daa053d39daf86b263374dce1b3959142a


Detailed log of new commits:

Author: azn
Date: Thu Dec 18 10:27:01 2014 +0300

    0025622: CAST analysis: Avoid invocation of virtual Methods of the declared Class in a Constructor or Destructor
    
    Virtual methods Delete() or Destroy() have been deleted in Destructors.
    Classes Graphic3d_DataStructureManager and PrsMgr_Presentation without changes.

abv

2014-12-26 14:00

manager   ~0035753

Last edited: 2014-12-26 14:00

Some remarks:

1. I suggest that empty destructors should be removed from classes whose base class already has virtual destructor:

math_MultipleVarFunctionWithHessian
math_MultipleVarFunctionWithGradient
math_FunctionWithDerivative
HatchGen_PointOnHatching
BRepSweep_Translation
BRepSweep_Trsf

2. There are many (~ 120) other classes not listed in description of this class (and not affected by the patch) that use the same approach to defining destructor via declaration of method Destroy() and using CDL alias to define destructor via that function. See e.g. XCAFDoc_DocumentTool. These classes should be addressed, too.

I suggest that this issue can address classes not inheriting Transient, while separate issue should be registered to eliminate method Destroy() in Transient and its descendants. Note that change in CDM_Document included in the current patch should be moved to that new issue.

git

2015-01-20 11:40

administrator   ~0036240

Branch CR25622 has been updated forcibly by azn.

SHA-1: c12fb8324715370d091b13dd005b4e3971cbbf0b

git

2015-01-20 11:43

administrator   ~0036241

Branch CR25622 has been updated forcibly by azn.

SHA-1: 70c123d89cc6d69477d845a56da00256c4c5bc43

azn

2015-01-20 12:00

developer   ~0036242

1. The above described classes have been fixed.
2. New issue 0025725 for Transient inheritors has been registered.
Please review.

abv

2015-01-20 16:06

manager   ~0036270

Reviewed, please test

git

2015-01-26 19:15

administrator   ~0036677

Branch CR25622 has been updated forcibly by apn.

SHA-1: 50ca699b3f22155e8b6d467a2039e1dbe01f5380

apn

2015-01-27 17:09

administrator   ~0036716

Dear BugMaster,
Branch CR25622 from occt git-repository (and master from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested in Release mode.
SHA-1: 50ca699b3f22155e8b6d467a2039e1dbe01f5380

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:
No regressions

Testing cases:
Not needed

Testing on Linux:
Total MEMORY difference: 369349344 / 370125320
Total CPU difference: 53429.45000000009 / 51750.87000000009

Testing on Windows:
Total MEMORY difference: 275356424 / 275769192
Total CPU difference: 37036.359375 / 38148.296875

There are not differences in images found by testdiff.

git

2015-03-18 13:34

administrator   ~0038532

Branch CR25622 has been deleted by inv.

SHA-1: 50ca699b3f22155e8b6d467a2039e1dbe01f5380

Related Changesets

occt: master 6da30ff1

2014-12-18 07:27:01

azn


Committer: bugmaster Details Diff
0025622: CAST analysis: Avoid invocation of virtual Methods of the declared Class in a Constructor or Destructor

The Delete() methods have been deleted from the following classes:
- Adaptor2d_Curve2d
- Adaptor3d_Curve
- Adaptor3d_Surface
- AppBlend_Approx
- AppCont_Function
- AppParCurves_MultiCurve
- AppParCurves_MultiPoint
- ApproxInt_SvSurfaces
- BRepPrim_OneAxis
- BRepSweep_NumLinearRegularSweep
- BRepSweep_Translation
- BRepSweep_Trsf
- DBC_BaseArray
- GeomFill_Profiler
- HatchGen_PointOnHatching
- math_BFGS
- math_FunctionSet
- math_FunctionSetRoot
- math_FunctionWithDerivative
- math_MultipleVarFunction
- math_MultipleVarFunctionWithHessian
- math_MultipleVarFunctionWithGradient
- math_Powell
- math_NewtonMinimum
- math_NewtonFunctionSetRoot
- math_BissecNewton (just add virtual destructor)
- math_FRPR
- math_BrentMinimum (just add virtual destructor)
- OSD_Chronometer
- ProjLib_Projector

Virtual methods Delete() or Destroy() of the transient inheritors is not changed (-> separate issue).
Classes Graphic3d_DataStructureManager and PrsMgr_Presentation without changes.
Affected Issues
0025622
mod - src/Adaptor2d/Adaptor2d_Curve2d.cdl Diff File
mod - src/Adaptor2d/Adaptor2d_Curve2d.cxx Diff File
mod - src/Adaptor3d/Adaptor3d_Curve.cdl Diff File
mod - src/Adaptor3d/Adaptor3d_Curve.cxx Diff File
mod - src/Adaptor3d/Adaptor3d_Surface.cdl Diff File
mod - src/Adaptor3d/Adaptor3d_Surface.cxx Diff File
mod - src/AppBlend/AppBlend_Approx.cdl Diff File
mod - src/AppBlend/AppBlend_Approx.cxx Diff File
mod - src/AppCont/AppCont_Function.hxx Diff File
mod - src/AppParCurves/AppParCurves_MultiCurve.cdl Diff File
mod - src/AppParCurves/AppParCurves_MultiCurve.cxx Diff File
mod - src/AppParCurves/AppParCurves_MultiPoint.cdl Diff File
mod - src/AppParCurves/AppParCurves_MultiPoint.cxx Diff File
mod - src/ApproxInt/ApproxInt_SvSurfaces.cdl Diff File
mod - src/ApproxInt/ApproxInt_SvSurfaces.cxx Diff File
mod - src/BRepPrim/BRepPrim_OneAxis.cdl Diff File
mod - src/BRepPrim/BRepPrim_OneAxis.cxx Diff File
mod - src/BRepSweep/BRepSweep_NumLinearRegularSweep.cdl Diff File
mod - src/BRepSweep/BRepSweep_NumLinearRegularSweep.cxx Diff File
mod - src/BRepSweep/BRepSweep_Translation.cdl Diff File
mod - src/BRepSweep/BRepSweep_Translation.cxx Diff File
mod - src/BRepSweep/BRepSweep_Trsf.cdl Diff File
mod - src/BRepSweep/BRepSweep_Trsf.cxx Diff File
mod - src/DBC/DBC_BaseArray.cdl Diff File
mod - src/DBC/DBC_BaseArray.cxx Diff File
mod - src/GeomFill/GeomFill_Profiler.cdl Diff File
mod - src/GeomFill/GeomFill_Profiler.cxx Diff File
mod - src/HatchGen/HatchGen_IntersectionPoint.cdl Diff File
mod - src/HatchGen/HatchGen_IntersectionPoint.cxx Diff File
mod - src/HatchGen/HatchGen_PointOnHatching.cdl Diff File
mod - src/HatchGen/HatchGen_PointOnHatching.cxx Diff File
mod - src/Interface/Interface_CopyTool.cdl Diff File
mod - src/Interface/Interface_CopyTool.cxx Diff File
mod - src/math/math_BFGS.cdl Diff File
mod - src/math/math_BFGS.cxx Diff File
mod - src/math/math_BissecNewton.cdl Diff File
mod - src/math/math_BissecNewton.cxx Diff File
mod - src/math/math_BrentMinimum.cdl Diff File
mod - src/math/math_BrentMinimum.cxx Diff File
mod - src/math/math_FRPR.cdl Diff File
mod - src/math/math_FRPR.cxx Diff File
mod - src/math/math_FunctionSet.cdl Diff File
mod - src/math/math_FunctionSet.cxx Diff File
mod - src/math/math_FunctionSetRoot.cdl Diff File
mod - src/math/math_FunctionSetRoot.cxx Diff File
mod - src/math/math_FunctionWithDerivative.cdl Diff File
mod - src/math/math_FunctionWithDerivative.cxx Diff File
mod - src/math/math_MultipleVarFunction.cdl Diff File
mod - src/math/math_MultipleVarFunction.cxx Diff File
mod - src/math/math_MultipleVarFunctionWithGradient.cdl Diff File
rm - src/math/math_MultipleVarFunctionWithGradient.cxx Diff File
mod - src/math/math_MultipleVarFunctionWithHessian.cdl Diff File
rm - src/math/math_MultipleVarFunctionWithHessian.cxx Diff File
mod - src/math/math_NewtonFunctionSetRoot.cdl Diff File
mod - src/math/math_NewtonFunctionSetRoot.cxx Diff File
mod - src/math/math_NewtonMinimum.cdl Diff File
mod - src/math/math_NewtonMinimum.cxx Diff File
mod - src/math/math_Powell.cdl Diff File
mod - src/math/math_Powell.cxx Diff File
mod - src/OSD/OSD_Chronometer.cdl Diff File
mod - src/OSD/OSD_Chronometer.cxx Diff File
mod - src/ProjLib/ProjLib_Projector.cdl Diff File
mod - src/ProjLib/ProjLib_Projector.cxx Diff File

Issue History

Date Modified Username Field Change
2014-12-16 18:04 azn New Issue
2014-12-16 18:04 azn Assigned To => azn
2014-12-18 10:28 git Note Added: 0035469
2014-12-18 10:30 azn Assigned To azn => abv
2014-12-18 10:30 azn Status new => resolved
2014-12-18 10:30 azn Steps to Reproduce Updated
2014-12-26 14:00 abv Note Added: 0035753
2014-12-26 14:00 abv Assigned To abv => azn
2014-12-26 14:00 abv Status resolved => assigned
2014-12-26 14:00 abv Note Edited: 0035753
2015-01-20 08:30 abv Relationship added related to 0025720
2015-01-20 11:40 git Note Added: 0036240
2015-01-20 11:43 git Note Added: 0036241
2015-01-20 11:54 azn Relationship added related to 0025725
2015-01-20 12:00 azn Note Added: 0036242
2015-01-20 12:00 azn Assigned To azn => abv
2015-01-20 12:00 azn Status assigned => resolved
2015-01-20 16:06 abv Note Added: 0036270
2015-01-20 16:06 abv Assigned To abv => bugmaster
2015-01-20 16:06 abv Status resolved => reviewed
2015-01-26 11:12 abv Relationship added has duplicate 0025577
2015-01-26 19:02 apn Assigned To bugmaster => apn
2015-01-26 19:15 git Note Added: 0036677
2015-01-27 17:09 apn Note Added: 0036716
2015-01-27 17:10 apn Test case number => Not needed
2015-01-27 17:10 apn Assigned To apn => bugmaster
2015-01-27 17:10 apn Status reviewed => tested
2015-01-30 14:00 bugmaster Changeset attached => occt master 6da30ff1
2015-01-30 14:00 bugmaster Status tested => verified
2015-01-30 14:00 bugmaster Resolution open => fixed
2015-03-18 13:34 git Note Added: 0038532
2015-05-14 15:29 aiv Status verified => closed
2015-05-14 15:32 aiv Fixed in Version => 6.9.0
2016-01-08 20:02 abv Relationship added related to 0027067