never-used inlines becoming statics
Martin von Loewis
martin@mira.isdn.cs.tu-berlin.de
Sun Sep 6 00:12:00 GMT 1998
> Weak symbols do _not_ remove common code - they allow an alternative
> entry point for a given symbol.
In general, you're right; code associated with weak symbols is copied
into the executable.
In this specific case, you're wrong. Template instantiations as
emitted by g++ 2.8 live in linkonce ELF sections. The GNU linker (and
any other linker honoring the linkonce bit) will put only one
instantiation of a template member into the executable, dropping all
the duplicates.
So, while it may seem unfortunate that the compiler instantiates
templates that are not used, this isn't that bad with some linker
support. This linker support is currently available for ELF and
Win32 PE.
Regards,
Martin
More information about the Gcc-bugs
mailing list