https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117630

--- Comment #14 from R. Diez <rdiez-2006 at rd10 dot de> ---
I do not understand why the compiler is generating
_GLOBAL__sub_I__ZSt20__throw_system_errori with the 2 atexit calls for
generic_category_instance and system_category_instance, or why the linker is
not optimizing it away.

In my small test program, nothing is actually calling __throw_system_error(). I
searched in the disassembly and in the map file, which includes a cross
reference table.

I also suspect that, the moment the static instance 'generic_category_instance'
lands in the ELF file, its vtable pulls in all virtual methods like:

virtual string message(int) const = 0;
virtual bool equivalent(int __i, const error_condition& __cond) const noexcept;

That happens even if those methods are never called. Apparently, GCC cannot
optimise unused virtual functions away, not even with LTO. Clang has allegedly
options like -fvirtual-function-elimination -fwhole-program-vtables to that
effect.

I do not think I will be able to get any further here without help.

Reply via email to