This is the mail archive of the
mailing list for the libstdc++ project.
more non-useless destructors desired
- From: Kenny Simpson <theonetruekenny at yahoo dot com>
- To: libstdc++ at gcc dot gnu dot org
- Date: Sat, 21 Mar 2009 08:48:29 -0700 (PDT)
- Subject: more non-useless destructors desired
- Reply-to: theonetruekenny at yahoo dot com
To prevent emitting typeinfo and vtable info in every translation unit, explicit destructors were added to some exceptions years ago - see r48700 and r48687.
However, there are a few more standard exceptions in <stdexcept> which are lacking these.
(logic_errors): domain_error, invalid_argument, length_error, out_of_range,
(runtime_errors): range_error, overflow_error, underflow_error
Is there some reason why these should not have explicit destructors too? Is it too late to add them due to ABI issues?
The reason this came up is that I recently had to debug an rather nasty bug due to some other rather nasty abuses in another project at work. During the investigation, I saw that the typeinfo and vtables for some of these destructors were being resolved against an old libstdc++ runtime.
Even though the symbols in the libstdc++ runtimes are versioned, the weak symbols emitted during compilation of the project are unversioned, so at runtime happened to resolve against the wrong one.
It is my understanding that if these exception had explicit destructors, then the vtable and typeinfo would not be emitted in the project's code, but that the resulting symbols would be normal undefined versioned symbols (as I did observe for std::exception).