https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89550
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> --- find_last_off returns npos (i.e. size_t(-1)) if the character is not found, and with that value remove_prefix is invalid. You get this warning whenever the compiler doesn't decide to unroll the loop or through some other optimization prove that the npos value will certainly not be returned. The number of n characters determines the length of the __PRETTY_FUNCTION__ string and thus also affects the decision if it should completely unroll the loop or not. Unfortunately, our current SCEV final value replacement isn't able to handle this, e.g. because the loop has multiple exits. Would be nice if we could try constexpr-like evaluation (JITing) loops and see if we can actually evaluate their final value even with multiple exits etc. As a workaround, perhaps use auto l = s.find_last_of(' '); if (l != std::string::npos) s.remove_prefix(l); ?