Given the following snippet:
#include <iostream>
#include <sstream>
int main()
{
std::stringstream str;
str.put('a');
str.put('\x80');
str.put('a');
str.ignore(32, '\x80'); // hangs
std::cout << str.tellg() << "\n";
}
If compiled with gcc, the marked line hangs, assembly step through indicates an infinite loop. I tried GCC 5.4, 6.3, 8.2, 9.2, on different OSes, the result is the same. On wandbox, also tried clang (that is probably coming with libc++ instead of libstdc++), it terminates fine.
It only happens if the second argument of ignore is a character with MSB set, and if there's at least one character before and after in the stream. Is this an error in libstdc++, or does the standard prohibit non-ascii delimiters?