https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77264
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Reduced:
#include <string>
int main () {
std::string str("xyz");
char c = 'Y';
str.replace(1, 1, &c, 1);
if (str[1] != 'Y')
__builtin_abort();
}