https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88508
Frank Heckenbach <f.heckenb...@fh-soft.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |f.heckenb...@fh-soft.de --- Comment #2 from Frank Heckenbach <f.heckenb...@fh-soft.de> --- According to https://stackoverflow.com/questions/57406448/canot-read-char8-t-from-basic-stringstreamchar8-t this seems to be the same issue, so I'm not filing a new bug, just adding a comment. Apparently this is no GCC bug, but according to the standard. IMHO this shows how ridiculous the current UTF-8 support is. A common I/O manipulator (setw) fails with an inscrutable error (bad cast, what cast?) which is even suppressed by default, unless enabled with o.exceptions, so by the default the stream just mysteriously stops working. And all that because the library doesn't know what the space character is in UTF-8. Just ranting, I know, but it's silly. % cat test.cpp #include <sstream> #include <fstream> #include <iomanip> int main () { std::basic_ostringstream <char8_t> o; o.exceptions (std::ifstream::badbit); o << std::setw (1) << u8""; } % g++ -std=c++20 -Wall -Wextra -o test test.cpp % ./test terminate called after throwing an instance of 'std::bad_cast' what(): std::bad_cast Aborted