Archived issue #0024209

Cppcheck errors "unusedScopedObject"

Open CASCADEOCCT:Codingclosed5 public notes

Search issues

Description

Cppcheck 1.61 (executed with option -DWNT on OCCT master at 6e5fec15) reports error "unusedScopedObject" at the following locations:

[src\Extrema\Extrema_GenExtCS.cxx:311]: (error) Instance of 'math_FunctionSetRoot' object is destroyed immediately.
[src\MeshTest\MeshTest.cxx:1244]: (error) Instance of 'BRepMesh_IncrementalMesh' object is destroyed immediately.
[src\Poly\Poly_CoherentTriangulation.cxx:593]: (error) Instance of 'Standard_ProgramError' object is destroyed immediately.
[src\Poly\Poly_CoherentTriangulation.cxx:668]: (error) Instance of 'Standard_ProgramError' object is destroyed immediately.
[src\QABugs\QABugs_19.cxx:129]: (error) Instance of 'BRepAlgo_Cut' object is destroyed immediately.
[src\StdSelect\StdSelect_BRepSelectionTool.cxx:88]: (error) Instance of 'BRepMesh_IncrementalMesh' object is destroyed immediately.
[src\TestTopOpe\TestTopOpe_HDSCommands.cxx:213]: (error) Instance of 'Standard_Failure' object is destroyed immediately.

Though many of them seem to be false positives, some indicate errors like absence of call to Raise() in exception throwing. False positives can be eliminated by rearranging code (when reasonable) or by adding suppression in comment before the offending code line (// cppcheck-suppress unusedScopedObject).

Public activity

5 archived notes

Participants are labeled by their role within this record.

01Commenter 1
Dear abv,
the fix has been integrated in branch CR24209.
Please, review.
02Commenter 2
Dear omy,

-    BRepMesh_IncrementalMesh(theShape, theDeflection, Standard_False, theDeviationAngle);
+    BRepMesh_IncrementalMesh aMesher(theShape, theDeflection, Standard_False, theDeviationAngle);
+    aMesher.Perform();

please pay attention on constructor description - Perform() will be called twice!
03Commenter 3
Dear abv,
Please review the branch CR24209_1.
04Commenter 4
No remarks, please test
05Commenter 5
Dear Commenter 1,

Branch CR24209_1 (and products from GIT master) was compiled on Linux and Windows platforms and tested.
[revision removed]

Number of compiler warnings:

occt component :
Linux: 104 (104 on master)
Windows: 1 (1 on master)

products component :
Linux: 21 (21 on master)
Windows: 2 (2 on master)

Regressions/Differences:
No regressions/differences

Testing cases:
Not needed

Testing on Linux:
Total MEMORY difference: 356975172 / 358413724
Total CPU difference: 44009.570000000225 / 42225.33000000005

Testing on Windows:
Total MEMORY difference: 413885388 / 412810244
Total CPU difference: 27774.953125 / 31505.90625

There are not differences in images found by testdiff.