libstdc++: Avoid overflow in istream::get(streambuf&) [LWG 3464]
Similar to the recent changes to basic_istream::ignore, this change
ensures that _M_gcount doesn't overflow when extracting characters and
inserting them into another streambuf.
The solution used here is to use unsigned long long for the count. We
assume that the number of characters extracted won't exceed the maximum
value for that type, but even if it does we avoid any undefined
behaviour.
libstdc++-v3/ChangeLog:
* include/bits/istream.tcc
(basic_istream::get(__streambuf_type&, char_type): Use unsigned
long long for counter and check if it would overflow _M_gcount.
* testsuite/27_io/basic_istream/get/char/lwg3464.cc: New test.
* testsuite/27_io/basic_istream/get/wchar_t/lwg3464.cc: New test.