[Bug report] Missing delete operator for placement new

OCC classes generated by WOK redefine a placement new operator:
void* operator new(size_t,void* anAddress)
{
return anAddress;
}
However there is no pair delete operator, which must be empty and as follows:
void operator delete (void*, void*)
{
}

Lack of this leads to numerous warnings that memory will not be freed if the constructor raises an exception.

Reproducer:

class MyPnt : public gp_Pnt
{
public:
#if 0
//compilation warning unless defined
void operator delete (void*, void*)
{
cerr }
#endif

MyPnt()
{
#if 0
//you may want to throw an exception here
throw int (0);
#endif
}
};

char b[sizeof (MyPnt)];
new (b) MyPnt();
reinterpret_cast (b)->~MyPnt();

The fix should be made in WOK generator, for all hierarchies (gp_Storable, Standard_Transient, Standard_Persistent, classes manipulated by value).

By the way, using this opportunity you may want to revisit WOK generator to avoid generation of redundant redefinitions of new/delete operators in subclasses of Standard_Transient and Standard_Persistent, as definition in a base class is sufficient.

Forum supervisor's picture

Dear Roman,
I would like to inform you that the posted problem has been checked confirmed.
The corresponding issue with ID = 22815 has been registered.
Later you may check if the issue is resolved by checking references to the specified ID in OCCT Release Notes. The analysis of the issue will take some time depending on our technical capability and availability of resources.
Regards

Fotis Sioutis's picture

Dear Forum Supervisor

Please note in your internal tracker that 'placement delete' should be protected by macros for compilers that support it.In my case borland c does not support it.I am not sure if there are any other compilers that do not support it.

ps : borland compilers define __BORLANDC__ macro

Forum supervisor's picture

Dear Fotis,
Your remark is registered and will be taken into account.
Regards