http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54392
--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-08-29 14:15:58 UTC --- Jon, didn't we somehow discuss this issue already, in a slightly different form (the issue of course was less evident pre that fix)? Thus, if I remember correctly what I was thinking at that time, a good general and safe fix would be tweaking a bit _M_disjunct, making it more careful so to speak, thus considering the address of the source as overlapping also if it corresponds to the '\0' at the end of destination. The philosophy in other terms is "preserving" the whole internal buffer, thus '\0' included. Matter of adding a + 1 somewhere, in other terms ;) If my analysis is correct, the fix would work as a special case for the test here involving empty reps, and I think it's the safe fix we want for the current std::string implementation at this stage.