llvm-project/libcxx/include
Mark de Wever 9393060f90 [libc++] Fixes std::to_chars for bases != 10.
While working on D70631, Microsoft's unit tests discovered an issue.
Our `std::to_chars` implementation for bases != 10 uses the range
`[first,last)` as temporary buffer. This violates the contract for
to_chars:
[charconv.to.chars]/1 http://eel.is/c++draft/charconv#to.chars-1
`to_chars_result to_chars(char* first, char* last, see below value, int base = 10);`
"If the member ec of the return value is such that the value is equal to
the value of a value-initialized errc, the conversion was successful and
the member ptr is the one-past-the-end pointer of the characters
written."

Our implementation modifies the range `[member ptr, last)`, which causes
Microsoft's test to fail. Their test verifies the buffer
`[member ptr, last)` is unchanged. (The test is only done when the
conversion is successful.)

While looking at the code I noticed the performance for bases != 10 also
is suboptimal. This is tracked in D97705.

This patch fixes the issue and adds a benchmark. This benchmark will be
used as baseline for D97705.

Reviewed By: #libc, Quuxplusone, zoecarver

Differential Revision: https://reviews.llvm.org/D100722
2021-04-29 19:56:28 +02:00
..
__iterator [libc++][ranges] iterator.concept.sizedsentinel: sized_sentinel_for and disable_sized_sentinel_for. 2021-04-26 15:06:19 -07:00
__memory [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
__ranges [libc++] Implements ranges::enable_borrowed_range 2021-04-18 13:35:08 +02:00
__support [SystemZ][z/OS] correct rc and errno within nanosleep() 2021-04-06 15:36:58 +00:00
__utility [libc++] Adds __utility/to_underlying.h. 2021-04-25 13:27:19 +02:00
experimental [libc++] Fix some typos and remove unused macros. NFCI. 2021-04-22 12:02:22 -04:00
ext [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
CMakeLists.txt [libc++] Support per-target __config_site in per-target runtime build 2021-04-28 14:27:16 -07:00
__availability [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
__bit_reference [libc++] __bit_iterator mustn't rely on deprecated SMF generation. 2021-04-26 16:22:42 -04:00
__bits [libc++] Fix some typos and remove unused macros. NFCI. 2021-04-22 12:02:22 -04:00
__bsd_locale_defaults.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
__bsd_locale_fallbacks.h Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
__config [libcxx] disables ranges for clang-cl 2021-04-23 18:21:33 -07:00
__config_site.in [libc++] Make LIBCXX_ENABLE_FILESYSTEM fully consistent 2021-01-19 14:15:48 -05:00
__debug [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
__errc [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
__functional_03 [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
__functional_base [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
__functional_base_03 [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
__hash_table [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
__libcpp_version [libcxx] Update include/__libcpp_version to match include/__config 2021-01-27 15:16:55 +00:00
__locale [libc++] s/_LIBCPP_NO_HAS_CHAR8_T/_LIBCPP_HAS_NO_CHAR8_T/g 2021-04-21 12:49:07 -04:00
__mutex_base [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
__node_handle [libc++] Fix some typos and remove unused macros. NFCI. 2021-04-22 12:02:22 -04:00
__nullptr [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
__split_buffer [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
__sso_allocator [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
__std_stream [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
__string [libc++] s/_LIBCPP_NO_HAS_CHAR8_T/_LIBCPP_HAS_NO_CHAR8_T/g 2021-04-21 12:49:07 -04:00
__threading_support [libcxx] Implement semaphores for windows 2021-03-05 10:48:59 +02:00
__tree [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
__tuple [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
__undef_macros Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
algorithm [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
any [libc++] Include <__config> first in all standard headers. 2021-03-22 19:01:18 -04:00
array [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
atomic [libc++] s/_LIBCPP_NO_HAS_CHAR8_T/_LIBCPP_HAS_NO_CHAR8_T/g 2021-04-21 12:49:07 -04:00
barrier [libc++] Remove hard tabs, U+00AD, and U+200B from all libc++ headers. NFCI. 2021-04-17 17:03:20 -04:00
bit [libc++] Rename include/support to include/__support 2021-02-04 10:16:33 -05:00
bitset [libc++] Remove if-else to make branch predictor happy 2021-04-24 16:09:52 +02:00
cassert Update more file headers across all of the LLVM projects in the monorepo 2019-01-19 10:56:40 +00:00
ccomplex [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
cctype [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
cerrno [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
cfenv [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
cfloat [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
charconv [libc++] Fixes std::to_chars for bases != 10. 2021-04-29 19:56:28 +02:00
chrono [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
cinttypes [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
ciso646 [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
climits [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
clocale [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
cmath [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
codecvt [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
compare [libc++] Eliminate <compare>'s dependency on <array>. 2021-03-25 10:34:35 -04:00
complex [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
complex.h [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
concepts [libc++] Add std::ranges::iter_move and std::iter_rvalue_reference_t 2021-04-21 11:32:00 -04:00
condition_variable [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
csetjmp [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
csignal [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
cstdarg [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
cstdbool [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
cstddef [libc++] s/_LIBCPP_NO_HAS_CHAR8_T/_LIBCPP_HAS_NO_CHAR8_T/g 2021-04-21 12:49:07 -04:00
cstdint [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
cstdio [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
cstdlib [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
cstring [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
ctgmath [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
ctime [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
ctype.h [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
cwchar [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
cwctype [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
deque [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
errno.h [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
exception [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
execution [pstl][libc++] Provide uglified header names for interface headers 2019-08-06 21:11:24 +00:00
fenv.h Mark fenv.h as a system header before the #include_next directive 2019-03-29 16:03:57 +00:00
filesystem [libc++] Remove the special logic for "noexcept iterators" in basic_string. 2021-04-26 16:22:43 -04:00
float.h [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
format [libc++][format] Enable format_error on older compilers. 2021-02-11 19:11:20 +01:00
forward_list [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
fstream [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
functional [libc++][ranges] Add range.cmp: equal_to, not_equal_to, less, etc. 2021-04-22 17:33:04 -07:00
future [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
initializer_list [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
inttypes.h [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
iomanip [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
ios [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
iosfwd [libc++] s/_LIBCPP_NO_HAS_CHAR8_T/_LIBCPP_HAS_NO_CHAR8_T/g 2021-04-21 12:49:07 -04:00
iostream [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
istream [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
iterator [libc++][ranges] iterator.concept.sizedsentinel: sized_sentinel_for and disable_sized_sentinel_for. 2021-04-26 15:06:19 -07:00
latch [libc++] [docs] Mark P1865 as complete since 11.0 as it was implemented together with P1135. Fix synopses in <barrier> and <latch>. 2020-12-06 15:36:52 +01:00
limits [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
limits.h [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
list [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
locale [libc++] Eliminate macro _LIBCPP_UNUSED_VAR. NFCI. 2021-04-22 12:02:22 -04:00
locale.h [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
map [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
math.h [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
memory [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
module.modulemap [libc++] Implements ranges::enable_borrowed_range 2021-04-18 13:35:08 +02:00
mutex [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
new [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
numbers [libcxx] cleans up __cpp_concepts mess 2021-02-26 18:43:40 +00:00
numeric [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
optional [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
ostream [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
queue [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
random [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
ranges [libc++] Implements ranges::enable_borrowed_range 2021-04-18 13:35:08 +02:00
ratio [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
regex [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
scoped_allocator [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
semaphore [libc++] Fix some one-off typos in comments. NFCI. 2020-12-14 09:54:58 -05:00
set [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
setjmp.h [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
shared_mutex [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
span [libc++] Implements ranges::enable_borrowed_range 2021-04-18 13:35:08 +02:00
sstream [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
stack [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
stdbool.h [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
stddef.h [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
stdexcept [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
stdint.h [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
stdio.h [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
stdlib.h [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
streambuf [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
string [libc++] Remove the special logic for "noexcept iterators" in basic_string. 2021-04-26 16:22:43 -04:00
string.h [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
string_view [libc++] s/_LIBCPP_NO_HAS_CHAR8_T/_LIBCPP_HAS_NO_CHAR8_T/g 2021-04-21 12:49:07 -04:00
strstream [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
system_error [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
tgmath.h [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
thread [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
tuple [libc++] Rewrite the tuple constructors to be strictly Standards conforming 2021-04-23 12:46:37 -04:00
type_traits [libc++] Rewrite the tuple constructors to be strictly Standards conforming 2021-04-23 12:46:37 -04:00
typeindex [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
typeinfo [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
unordered_map [libc++] Fix some typos and remove unused macros. NFCI. 2021-04-22 12:02:22 -04:00
unordered_set [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
utility [libc++] Adds __utility/to_underlying.h. 2021-04-25 13:27:19 +02:00
valarray [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
variant [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
vector [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
version [libc++] s/_LIBCPP_NO_HAS_CHAR8_T/_LIBCPP_HAS_NO_CHAR8_T/g 2021-04-21 12:49:07 -04:00
wchar.h [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00
wctype.h [libc++] NFC: Normalize `#endif //` comment indentation 2021-04-20 12:03:32 -04:00