<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - to_chars can puts leading zeros on numbers"
   href="https://bugs.llvm.org/show_bug.cgi?id=42166">42166</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>to_chars can puts leading zeros on numbers
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libc++
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>All Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>mclow.lists@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Given the following code:
------
#include <charconv>
#include <iostream>
#include <cassert>

template <typename T>
void test()
{
        char buf[100];
        auto res = std::to_chars(buf, buf + 100, (T)0xffffffff);
        assert(res.ec == std::errc());
        *res.ptr = '\0';
        std::cout << (const char *) buf << std::endl;
}

int main ()
{
        test<int>();
        test<long>();
        test<int64_t>();

        test<unsigned int>();
        test<unsigned long>();
        test<uint64_t>();
}
-----

I expect this to print:
-1
4294967295
4294967295
4294967295
4294967295
4294967295


but instead it prints:
-1
0004294967295
0004294967295
4294967295
0004294967295
0004294967295</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>