This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Generic questions on inline functions and linking


Thanks for the detailed explanation of ODR. :)

On Wed, Jul 22, 2015 at 2:45 AM, Jonathan Wakely <jwakely@redhat.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
above one.

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
improvement.

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
difference?

Thanks :)


-- 
Regards,
Tim Shen


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]