I made a simple logger for my OS to make the debugging process easier. (I'm at a stage where I don't even have the IDT set up for all IRQs and exceptions, let alone new and delete)
Whenever I try to add a virtual destructor it results in an undefined reference to operator delete.
I can obviously add a stub, but why does it even need operator delete here? What is it trying to delete?
It compiles and links successfully when I remove the virtual destructor (which is also fine I guess).
https://prnt.sc/sj41qh
https://prnt.sc/sj4165
EDIT: I added a stub and it's not actually getting called ever, im confused
Undefined reference to operator delete
-
- Member
- Posts: 5575
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Undefined reference to operator delete
This link may help.
In short, the ABI requires the compiler to generate that function call for all virtual destructors, but it will only be called if you use new/delete to create/destroy an object of that class. Since you're not going to do that, it should never be called.
Since it should never be called, your stub operator delete can call your kernel's panic handler to halt and inform you that something bad happened.
In short, the ABI requires the compiler to generate that function call for all virtual destructors, but it will only be called if you use new/delete to create/destroy an object of that class. Since you're not going to do that, it should never be called.
Since it should never be called, your stub operator delete can call your kernel's panic handler to halt and inform you that something bad happened.
Re: Undefined reference to operator delete
Oh, great! thanks!Octocontrabass wrote:This link may help.
In short, the ABI requires the compiler to generate that function call for all virtual destructors, but it will only be called if you use new/delete to create/destroy an object of that class. Since you're not going to do that, it should never be called.
Since it should never be called, your stub operator delete can call your kernel's panic handler to halt and inform you that something bad happened.