This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 4/7] Class-fy partial_die_info
>> std::is_trivially_destructible to enforce the rule that objects on an
>> obstack can't really be destroyed. This would eliminate the separate
>> XOBNEW, which is maybe a potential source of errors; and would also make
>> it harder to accidentally add a destructor to objects allocated this way
Yao> but why dtor must be trivial? We can have "operator new" and "operator
Yao> delete", the former allocate spaces on obstack and the latter doesn't
Yao> de-allocate space. It doesn't matter dtor is trivial or not. I may
Yao> miss something here.
My thinking was that if something is allocated on an obstack, then
presumably the destructor will never be run. So, it's best to avoid
confusion by requiring a trivial destructor.
I suppose it would be possible to track objects and destroy them, but if
that's done, then it sort of eliminates the point of an obstack -- it
would be just as convenient at that point to use the ordinary new.
Yao> Further, I think IWBN to have a class which has new/delete operator,
Yao> and other classes can inherit it. What do you think the patch below?
I suppose this makes sense if you know that all objects of a given type
must be allocated on an obstack.
Tom