[libcxx-commits] [libcxx] 3e87719 - [libc++] Fix initialization of __fill_
Jake Egan via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Mar 3 06:28:56 PST 2022
Author: Jake Egan
Date: 2022-03-03T09:28:49-05:00
New Revision: 3e87719177296a80ebf3fbf801a6f75799d2fe5e
URL: https://github.com/llvm/llvm-project/commit/3e87719177296a80ebf3fbf801a6f75799d2fe5e
DIFF: https://github.com/llvm/llvm-project/commit/3e87719177296a80ebf3fbf801a6f75799d2fe5e.diff
LOG: [libc++] Fix initialization of __fill_
`basic_ios` delays initialization of `__fill_` to `widen(' ')` until `fill()` is called. But, `fill(char_type)` is missing this logic, so the fill character does not get initialized to whitespace if `fill(char_type)` is called first. This patch adds this logic to `fill(char_type)`.
Reviewed By: #libc, ldionne, Quuxplusone
Differential Revision: https://reviews.llvm.org/D120751
Added:
Modified:
libcxx/include/ios
libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/fill_char_type.pass.cpp
Removed:
################################################################################
diff --git a/libcxx/include/ios b/libcxx/include/ios
index d179f0c242000..874227ac73ef7 100644
--- a/libcxx/include/ios
+++ b/libcxx/include/ios
@@ -781,6 +781,8 @@ inline _LIBCPP_INLINE_VISIBILITY
_CharT
basic_ios<_CharT, _Traits>::fill(char_type __ch)
{
+ if (traits_type::eq_int_type(traits_type::eof(), __fill_))
+ __fill_ = widen(' ');
char_type __r = __fill_;
__fill_ = __ch;
return __r;
diff --git a/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/fill_char_type.pass.cpp b/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/fill_char_type.pass.cpp
index b2d593bbd768d..ae8ecece80856 100644
--- a/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/fill_char_type.pass.cpp
+++ b/libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/fill_char_type.pass.cpp
@@ -20,7 +20,6 @@
int main(int, char**)
{
std::ios ios(0);
- assert(ios.fill() == ' ');
char c = ios.fill('*');
assert(c == ' ');
assert(ios.fill() == '*');
More information about the libcxx-commits
mailing list