[llvm-bugs] [Bug 42166] New: to_chars can puts leading zeros on numbers
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Jun 6 08:47:47 PDT 2019
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: unassignedclangbugs at nondot.org
Reporter: mclow.lists at gmail.com
CC: llvm-bugs at lists.llvm.org, mclow.lists at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190606/249f201f/attachment.html>
More information about the llvm-bugs
mailing list