https://bugs.llvm.org/show_bug.cgi?id=42166
Bug ID: 42166
Summary: to_chars can puts leading zeros on numbers
Product: libc++
Version: unspecified
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: All Bugs
Assignee: unassignedclangb...@nondot.org
Reporter: mclow.li...@gmail.com
CC: llvm-bugs@lists.llvm.org, mclow.li...@gmail.com
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
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs