https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119880
Bug ID: 119880 Summary: fwide must be called before and after std::wcout to change wide orientation to allow std::cout works Product: gcc Version: 16.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: nickhuang99 at hotmail dot com Target Milestone: --- See following program which requires the first "fwide" so as to allow "std::cout" to work after "std::wcout" calls. This behavior is only with GCC library and MSVC latest can comment the first "fwide" out. This indicates a bug in implementation of GCC stdlib. #include <cwchar> #include <iostream> #include <ostream> #include <cstdio> int main() { //std::fwide(stdout, -1); // you cannot comment out this line for GCC!!! std::wcout << L"This is a wide line from local wcout." << std::endl; std::fwide(stdout, -1); std::cout << "This is a narrow line after wide output." << std::endl; return 0; } In GCC family, only "std::wcout" prints while "std::cout" fails to print because stdout is still wide oriented. This can be confirmed by a test "fwide(stdout, 0) > 0" after "std::wcout" prints. See www.godbolt.org at https://www.godbolt.org/z/63Gh3xGMh