[libcxx-commits] [PATCH] D63047: [libc++] Fix leading zeros in std::to_chars

Afanasyev Ivan via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sat Jun 8 07:20:19 PDT 2019


ivafanas created this revision.
ivafanas added reviewers: lichray, mclow.lists, ldionne, EricWF.
Herald added subscribers: libcxx-commits, dexonsmith, christof.

It is a bugfix proposal for https://bugs.llvm.org/show_bug.cgi?id=42166.

`std::to_chars` appends leading zeros if input 64-bit value has 9, 10 or 11 digits.
According to documentation `std::to_chars` must not append leading zeros:
https://en.cppreference.com/w/cpp/utility/to_chars

Changeset should not affect `std::to_chars` performance:
http://quick-bench.com/CEpRs14xxA9WLvkXFtaJ3TWOVAg

Unit test that `std::from_chars` supports compatibility for both `std::to_chars` outputs (previous and fixed one) already exists:
https://github.com/llvm-mirror/libcxx/blob/1f60111b597e5cb80a4513ec86f79b7e137f7793/test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp#L63


Repository:
  rCXX libc++

https://reviews.llvm.org/D63047

Files:
  libcxx/src/charconv.cpp
  libcxx/test/std/utilities/charconv/charconv.to.chars/integral.pass.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63047.203688.patch
Type: text/x-patch
Size: 10881 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20190608/a8d3101c/attachment.bin>


More information about the libcxx-commits mailing list