When we extract wide characters and insert them into a stringstream to
be parsed as a floating-point value, we should use a stringstream of
char, not wchar_t.
libstdc++-v3/ChangeLog:
PR libstdc++/123147
* include/bits/chrono_io.h (_Parser::operator()) <%S>: Use a
buffer of narrow characters to be parsed by std::from_chars.
* testsuite/std/time/parse/parse.cc: Check wchar_t parsing.
}
else // Read fractional seconds
{
- basic_stringstream<_CharT> __buf;
+ stringstream __buf;
auto __digit = _S_try_read_digit(__is, __err);
if (__digit != -1)
{
- __buf.put(_CharT('0') + __digit);
+ __buf.put('0' + __digit);
__digit = _S_try_read_digit(__is, __err);
if (__digit != -1)
- __buf.put(_CharT('0') + __digit);
+ __buf.put('0' + __digit);
}
auto __i = __is.peek();
{
__digit = _S_try_read_digit(__is, __err);
if (__digit != -1)
- __buf.put(_CharT('0') + __digit);
+ __buf.put('0' + __digit);
else
break;
}
VERIFY( s == 12s );
}
+void
+test_wchar()
+{
+ std::wistringstream is;
+ std::chrono::duration<double, std::milli> ms;
+
+ is.clear();
+ is.str(L"0.125");
+ is >> parse(L"%S", ms);
+ VERIFY( is.good() );
+ VERIFY( ms.count() == 125 );
+}
+
int main()
{
test_recommended_practice();
test_whitespace();
test_errors();
test_modifiers();
+ test_wchar();
}