http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54392
--- Comment #7 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-08-29 15:13:57 UTC --- Thus, I guess the right thing to do is sort-of the other way around of what I was thinking: change _M_disjunct in such a way that when the destination is the empty rep it always returns true, thus we first allocate memory for the destination and then copy the '\0' to it and everything is fine (nothing bad can happen to the source in this special case because the empty rep source isn't in dynamically allocated memory, thus isn't deallocated, it stays in memory forever).