[libcxx-commits] [PATCH] D120751: [libc++] Fix initialization of __fill_

Jake Egan via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Mar 2 06:39:47 PST 2022


Jake-Egan updated this revision to Diff 412399.
Jake-Egan added a comment.
Herald added a project: All.

Thanks for the review. I removed the flag and modified the existing test for fill(char_type) to test the initialization of the fill character on the first call. This test was passing because it called fill() first in the assert.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D120751/new/

https://reviews.llvm.org/D120751

Files:
  libcxx/include/ios
  libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/fill_char_type.pass.cpp


Index: libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/fill_char_type.pass.cpp
===================================================================
--- libcxx/test/std/input.output/iostreams.base/ios/basic.ios.members/fill_char_type.pass.cpp
+++ 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() == '*');
Index: libcxx/include/ios
===================================================================
--- libcxx/include/ios
+++ libcxx/include/ios
@@ -781,6 +781,8 @@
 _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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120751.412399.patch
Type: text/x-patch
Size: 919 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220302/f9d5b269/attachment.bin>


More information about the libcxx-commits mailing list