https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88512
--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> --- It's easy for you to say that after looking at the reason it failed and knowing what the code is trying to do (obviously "insert" modifies the string, so it can't be const). But the compiler has to try every overload, and doesn't know what your intention is, or what the word "insert" means. The problem here is (as before) that std::string has eight overloads of insert (and just as many for assign, and begin, and replace etc), and there's nothing the compiler can do about that. Potentially the compiler could be changed so that if all the overload candidates are non-const and the object is const, it just says that. But that's another fairly specialized diagnostic just for this case. Most classes simply don't have eight overloads of the same function.