You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Classes like f2c::obj::BaseObjective have virtual methods but no virtual destructors.
For example, this function from fields2cover.cpp
std::unique_ptr<obj::SGObjective> getSGObjPtr(const Options& opt) {
std::unique_ptr<obj::SGObjective> ptr;
switch (opt.sg_obj) {
case SGObjFunc::N_SWATH_MOD:
ptr = std::make_unique<obj::NSwathModified>();
break;
case SGObjFunc::N_SWATH:
ptr = std::make_unique<obj::NSwath>();
break;
case SGObjFunc::SWATH_LENGTH:
ptr = std::make_unique<obj::SwathLength>();
break;
case SGObjFunc::FIELD_COV:
ptr = std::make_unique<obj::SwathLength>();
break;
case SGObjFunc::OVERLAPS:
ptr = std::make_unique<obj::Overlaps>();
break;
}
return ptr;
}
When the returned unique pointer is destroyed, it calls the SGObjective destructor, and not any of the obj::NSwathModified, obj::NSwath, obj::SwathLength, obj::SwathLength, or obj::Overlaps destructors.
This is undefined behavior.
The text was updated successfully, but these errors were encountered:
Classes like f2c::obj::BaseObjective have virtual methods but no virtual destructors.
For example, this function from
fields2cover.cpp
When the returned unique pointer is destroyed, it calls the SGObjective destructor, and not any of the obj::NSwathModified, obj::NSwath, obj::SwathLength, obj::SwathLength, or obj::Overlaps destructors.
This is undefined behavior.
The text was updated successfully, but these errors were encountered: