https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103655
Bug ID: 103655 Summary: "x" does not exist on windows and dos Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: unlvsur at live dot com Target Milestone: --- In today's patch. https://github.com/gcc-mirror/gcc/commit/a219139e986a4200a9105d7c1fa63735d2945994 std::ios::noreplace uses "x". However, that is not correctly supported by msvcrt and dos djgpp. The correct way is to directly use CreateFileW (on windows NT) or NtCreateFile and CreateFileA on windows 9x. Then call _open_osfhandle to create an fd then call _wfdopen(on windows NT) or _fdopen(on windows 9x) on Windows Create an NT handle with NtCreateFile (You also need RtlNtStatusToDosError and RtlDosPathNameToNtPathName_U_WithStatus or RtlDosPathNameToNtPathName_U). https://github.com/tearosccebe/fast_io/blob/6081ae18b34820c3c69b81628f520f5fafcfb815/include/fast_io_hosted/platforms/nt.h#L67 Or create a win32 handle with CreateFileA (on Windows 9x) and CreateFileW (on Windows NT) https://github.com/tearosccebe/fast_io/blob/6081ae18b34820c3c69b81628f520f5fafcfb815/include/fast_io_hosted/platforms/win32.h#L201 Use win32 or nt handle to call _open_osfhandle to create a POSIX fd. https://github.com/tearosccebe/fast_io/blob/6081ae18b34820c3c69b81628f520f5fafcfb815/include/fast_io_hosted/platforms/posix.h#L58 https://github.com/tearosccebe/fast_io/blob/6081ae18b34820c3c69b81628f520f5fafcfb815/include/fast_io_hosted/platforms/posix.h#L961 Then use _wfdopen on Windows NT and _fdopen on Windows 9x to open a FILE* https://github.com/tearosccebe/fast_io/blob/6081ae18b34820c3c69b81628f520f5fafcfb815/include/fast_io_legacy_impl/c/impl.h#L29 Then construct a std::filebuf with FILE* https://github.com/tearosccebe/fast_io/blob/6081ae18b34820c3c69b81628f520f5fafcfb815/include/fast_io_legacy_impl/filebuf/filebuf_file.h#L60 On DOS. You need __dos_creat,__dos_creatnew,__dos_open https://github.com/tearosccebe/fast_io/blob/6081ae18b34820c3c69b81628f520f5fafcfb815/include/fast_io_hosted/platforms/posix.h#L1063 So libstdc++ using fdopen to open FILE* with fd is incorrect. On windows NT kernel, we MUST use _wfdopen since _fdopen involves locale, which is not thread-safe.