basic_string.tcc contains 'extern template basic_string<char>', which prevents the template from being instantiated, and thus all calls to basic_string methods remain calls even at -O3.
If I -D_GLIBCXX_DEBUG=1 _GLIBCXX_EXTERN_TEMPLATE is 0, thus it will no longer contain 'extern template basic_string<char>', so the body of methods will be available, and inlining will be performed. However _GLIBCXX_DEBUG=1 activates debug code, so I would like to be able to get the methods inlined w/o definining debug mode. Can the semantics of 'extern template' be changed [*] in such a way, that *if* the body of some of the methods are suitable for inlining, they will be inlined (and other methods won't get instantiated), and if none of the methods are suitable, the behaviour stays as currently. [*] by introducing a new compiler flag, that can be activated at -O3 (and maybe -O2) at the expense of code size. -- Summary: std::string is faster with -D_GLIBCXX_DEBUG=1 than without Product: gcc Version: 4.3.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: edwintorok at gmail dot com GCC build triplet: x86_64-linux-gnu GCC host triplet: x86_64-linux-gnu GCC target triplet: x86_64-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38132