forked from OSchip/llvm-project
[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
This commit is contained in:
parent
e9302bf7ef
commit
3e87719177
|
@ -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;
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
int main(int, char**)
|
||||
{
|
||||
std::ios ios(0);
|
||||
assert(ios.fill() == ' ');
|
||||
char c = ios.fill('*');
|
||||
assert(c == ' ');
|
||||
assert(ios.fill() == '*');
|
||||
|
|
Loading…
Reference in New Issue