This is the mail archive of the
mailing list for the libstdc++ project.
Re: Generic questions on inline functions and linking
- From: Tim Shen <timshen at google dot com>
- To: Jonathan Wakely <jwakely at redhat dot com>
- Cc: "libstdc++" <libstdc++ at gcc dot gnu dot org>
- Date: Wed, 22 Jul 2015 21:36:42 -0700
- Subject: Re: Generic questions on inline functions and linking
- Authentication-results: sourceware.org; auth=none
- References: <CAG4ZjNmGfTcZcuZoo=Z8mV7J+RHW1ZN0NbDrrMSPR_6+mi9zQQ at mail dot gmail dot com> <20150722094510 dot GW21787 at redhat dot com>
Thanks for the detailed explanation of ODR. :)
On Wed, Jul 22, 2015 at 2:45 AM, Jonathan Wakely <email@example.com> wrote:
>> really good to keep them inlined since they are anyway in the header,
>> and there is no real reason should we let use to keep multiple copies
>> in an executable.
> I don't think I understand this last sentence, because you won't get
> multiple copies kept in the executable anyway, the linker will only
> keep one copy of each symbol in the final executable.
Sorry, I misunderstood template functions a bit; it turns out I also
observed a different thing, that's not necessarily related to the
My observation is: adding inline specifier to a *template* member
function definition outside of its class scope improves the
performance and reduces the binary size.
Taking trunk as an exmaple. I added inline for each function in
include/bits/regex_executor.tcc, and recompiled a file that is similar
to our check-performance test file, then I observed a reduced binary
size (with 3 less exported symbols) and slight performance
I tried to read the standard for whether a template member function
definition is implicitly inline, but failed :P. If it's true, then why
do we have different generated code here? If it's false, what's the