Archived issue #0025074

Intf_Polygon2d - add virtual destructor

CommunityOCCT:Codingclosed5 public notes

Search issues

Description

I received the following warnings when compiling:
In file included from /src/IntCurve/IntCurve_IntPolyPolyGen.gxx:47:0,
                 from \drv\Geom2dInt\Geom2dInt_TheIntPCurvePCurveOfGInter_0.cxx:45:
/src/NCollection/NCollection_Handle.hxx: In instantiation of 'NCollection_Handle<T>::Ptr::~Ptr() [with T = Geom2dInt_ThePolygon2dOfTheIntPCurvePCurveOfGInter]':
/src/IntCurve/IntCurve_IntPolyPolyGen.gxx:1032:1:   required from here
/src/NCollection/NCollection_Handle.hxx:62:28: warning: deleting object of polymorphic class type 'Geom2dInt_ThePolygon2dOfTheIntPCurvePCurveOfGInter' which has non-virtual destructor might cause undefined behaviour [-Wdelete-non-virtual-dtor]
     ~Ptr () { if ( myPtr ) delete myPtr; myPtr = 0; }
                            ^

In file included from /src/IntCurve/IntCurve_IntPolyPolyGen.gxx:47:0,
                 from \drv\HLRBRep\HLRBRep_TheIntPCurvePCurveOfCInter_0.cxx:42:
/src/NCollection/NCollection_Handle.hxx: In instantiation of 'NCollection_Handle<T>::Ptr::~Ptr() [with T = HLRBRep_ThePolygon2dOfTheIntPCurvePCurveOfCInter]':
/src/IntCurve/IntCurve_IntPolyPolyGen.gxx:1032:1:   required from here
/src/NCollection/NCollection_Handle.hxx:62:28: warning: deleting object of polymorphic class type 'HLRBRep_ThePolygon2dOfTheIntPCurvePCurveOfCInter' which has non-virtual destructor might cause undefined behaviour [-Wdelete-non-virtual-dtor]
     ~Ptr () { if ( myPtr ) delete myPtr; myPtr = 0; }
                            ^


My C++ OOP knowledge is minimal, so I will leave it up to OCCT devs to determine whether this is meaningful or not.

Public activity

5 archived notes

Participants are labeled by their role within this record.

01Commenter 2
Patch is ready for review in branch CR25074.
02Author
Hi, related to the original posted problem:

[user path removed]/oce/src/Voxel/Voxel_CollisionDetection.cxx: In member function ‘void Voxel_CollisionDetection::Clear()’:
[user path removed]/oce/src/Voxel/Voxel_CollisionDetection.cxx:274:36: warning: deleting object of polymorphic class type ‘Voxel_BoolDS’ which has non-virtual destructor might cause undefined behaviour [-Wdelete-non-virtual-dtor]
     delete ((Voxel_BoolDS*)myVoxels);
                                    ^
03Commenter 2
Please test the patch.
04Commenter 4
Dear Commenter 1,

Branch CR25074 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: 15 (15 on master)
Windows: 0 (0 on master)
MacOS: 197 (199 on master)

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

Regressions/Differences:
No regressions/differences

Testing cases:
Not needed

Testing on Linux:
Total MEMORY difference: 352228684 / 352287924
Total CPU difference: 60689.039999999935 / 54524.449999999866

Testing on Windows:
Total MEMORY difference: 377724552 / 378502168
Total CPU difference: 37160.359375 / 46775.625

There are no differences in images found by testdiff.
05Commenter 3
Branch [archived branch] has been deleted by Participant.

[revision removed]