https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87502
--- Comment #2 from M Welinder <terra at gnome dot org> --- Created attachment 44789 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44789&action=edit Proof-on-concept patch This proof-of-concept improves the situation dramatically. I don't know if it is actually correct. This is done, in part, by not discarding the fact that the source is zero-terminated. With this patch I get the code I expect, mostly. For sizes 2 mod 4 I still get the zero termination as a separate movb. The destruction still stinks: the full destructor is inlined instead of the small-string-only version (i.e., a no-op). Evidently gcc cannot see that the string remains a small-string.