Generic questions on inline functions and linking

Tim Shen timshen@google.com
Wed Jul 22 05:16:00 GMT 2015


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



More information about the Libstdc++ mailing list