This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Generic questions on inline functions and linking
- From: Tim Shen <timshen at google dot com>
- To: "libstdc++" <libstdc++ at gcc dot gnu dot org>
- Date: Tue, 21 Jul 2015 22:16:43 -0700
- Subject: Generic questions on inline functions and linking
- Authentication-results: sourceware.org; auth=none
If a user compiled two object files, one with exception (or rtti,
doesn't matter) turned on, but another without, and links them
together, such a function in libstdc++ may be problematic:
inline void __foo()
{
__try
{
// ...
}
__catch(...)
{
// ...
}
}
since it's an odr violation.
Should the user be responsible for this, or we should avoid writing
such a thing? I guess it applies to template functions as well?
I raise this because recently I'm refactoring regex library, and found
that marking the giant regex library inlined (including template
function) improves >10% time efficiency and reduces binary size. It's
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.
Thanks!
--
Regards,
Tim Shen