4 ms·
also an operator delete is very much not required if you give a base class a virtual destructor, only if you are using a custom allocator; probably the OP is mi
by gpderetta 10y ago
also an operator delete is very much not required if you give a base class a virtual destructor, only if you are using a custom allocator; probably the OP is missing something in his description.
- lultimouomo 10y agoThis is not about defining a custom operator delete, it's about defining it at all, because when compiling with -ffreestanding it is not provided, and apparently virtual destructors synthesize call to the delete operator.
- gpderetta 10y agothat's kind of circular... having a virtual destructor is useful only if you actually are going to call delete. If you want to make sure that the object is never heap allocated, just declare the operator new as deleted and at least the issue would be always caught at compile time instead of just having a chance of catching it a runtime.
- lultimouomo 10y agoI agree, that was the sense of my original comment. Actually, most probably you don't even need to delete it as it's not defined with -ffreestanding