https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110990

            Bug ID: 110990
           Summary: `format_to_n` returns wrong value
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ensadc at mailnesia dot com
  Target Milestone: ---

https://godbolt.org/z/4fv71hhGe
====
#include <format>
#include <iostream>

int main() {
    char buf[10] = "@@@@@@@@@";
    auto result = std::format_to_n(buf, std::size(buf), "a");

    std::cout << result.out - buf << '\n';
}

====
On libstdc++, `result.out - buf` evaluates to 10. I expect it to be 1. Both
libc++ and MSVC STL produce 1.

Reply via email to