[Bug ipa/93921] -Os generates much bigger code than -O{1,2,3,fast} for std::string::size
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Feb 25 10:55:00 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93921
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Bjørnar Snoksrud from comment #3)
> Using '--std=c++20 -Os' generates minimal code.
That disables the explicit template instantiation declarations for std::string,
so the compiler performs implicit instantiations and then inlines the code.
Without C++20 the compiler sees the explicit instantiation declarations (i.e.
the 'extern template' declarations) and emits calls to those external
definitions, without inlining anything.
I think GCC needs to be better at deciding when to ignore the explicit
instantiations and to do implicit instantiations anyway.
More information about the Gcc-bugs
mailing list