-
Notifications
You must be signed in to change notification settings - Fork 67
Description
When compiling with gcc and -Wall:
Exhibit A
This generated code leads to a gcc warning on the delete arg1 line:
warning: deleting object of abstract class type ‘eprosima::fastdds::dds::LoanableTypedCollection<HelloWorld, std::integral_constant<bool, false> >’ which has non-virtual destructor will cause undefined behavior [-Wdelete-non-virtual-dtor]
SWIGINTERN PyObject *_wrap_delete__HelloWorldSeq(PyObject *self, PyObject *args) {
PyObject *resultobj = 0;
eprosima::fastdds::dds::LoanableTypedCollection< HelloWorld,std::false_type > *arg1 = 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
PyObject *swig_obj[1] ;
(void)self;
if (!args) SWIG_fail;
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_eprosima__fastdds__dds__LoanableTypedCollectionT_HelloWorld_std__false_type_t, SWIG_POINTER_DISOWN | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete__HelloWorldSeq" "', argument " "1"" of type '" "eprosima::fastdds::dds::LoanableTypedCollection< HelloWorld,std::false_type > *""'");
}
arg1 = reinterpret_cast< eprosima::fastdds::dds::LoanableTypedCollection< HelloWorld,std::false_type > * >(argp1);
delete arg1; // <--------- WARNING HERE
resultobj = SWIG_Py_Void();
return resultobj;
fail:
return NULL;
}Exhibit B
Similarly, this generated code leads to a warning on the delete arg1 line:
warning: deleting object of polymorphic class type ‘eprosima::fastdds::dds::LoanableSequence<HelloWorld, std::integral_constant<bool, false> >’ which has non-virtual destructor might cause undefined behavior [-Wdelete-non-virtual-dtor]
SWIGINTERN PyObject *_wrap_delete_HelloWorldSeq(PyObject *self, PyObject *args) {
PyObject *resultobj = 0;
eprosima::fastdds::dds::LoanableSequence< HelloWorld,std::false_type > *arg1 = 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
PyObject *swig_obj[1] ;
(void)self;
if (!args) SWIG_fail;
swig_obj[0] = args;
res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_eprosima__fastdds__dds__LoanableSequenceT_HelloWorld_std__false_type_t, SWIG_POINTER_DISOWN | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_HelloWorldSeq" "', argument " "1"" of type '" "eprosima::fastdds::dds::LoanableSequence< HelloWorld,std::false_type > *""'");
}
arg1 = reinterpret_cast< eprosima::fastdds::dds::LoanableSequence< HelloWorld,std::false_type > * >(argp1);
delete arg1; // <--------- WARNING HERE
resultobj = SWIG_Py_Void();
return resultobj;
fail:
return NULL;
}Would be awesome if these could be fixed!
Maybe adding a virtual destructor to LoanableTypedCollection and LoanableSequence would work?
Thanks!