https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81068
--- Comment #7 from Piotr Stachura <piotr.stachura at delphi dot com> --- Jonathan, you are right. In sample code, end of string should be input_data[8]. With this correction I have this same behavior on both systems that I use (correct compilation and execution without sanitizer and memory leak when sanitizer is enabled). For clarification about Ubuntu system. When code is compiled with input end at input_data[8] then output string is following: 0x22 0x44 0x80 0x156 0x34b When compiled with input_data[7] last character is not present in output string (as expected, since not full UTF-8 character is in input). This same can be archived when compiled with end at input_data[6] at all systems. Memory leak is also shown when compiled with clang (4.0) with sanitizers.