diff --git a/include/fmt/format.h b/include/fmt/format.h index a98e41d9e68e..4104d91fc7cd 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1958,11 +1958,12 @@ auto write_escaped_string(OutputIt out, basic_string_view str) template auto write_escaped_char(OutputIt out, Char v) -> OutputIt { + Char v_array[1] = {v}; *out++ = static_cast('\''); if ((needs_escape(static_cast(v)) && v != static_cast('"')) || v == static_cast('\'')) { out = write_escaped_cp( - out, find_escape_result{&v, &v + 1, static_cast(v)}); + out, find_escape_result{v_array, v_array + 1, static_cast(v)}); } else { *out++ = v; }