https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80811
--- Comment #4 from Marc Glisse <glisse at gcc dot gnu.org> --- When user specializations are allowed, who knows what might happen. As an experiment, namespace std { extern template __attribute__((pure)) int string::compare(const char*)const; } seems to work. I think it may make sense to add the attribute only in the extern template case, since that's the case where the explicit instantiation is hindering IPA.