https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115524
Bug ID: 115524 Summary: Cygwin: Space character categorized as non-printable by std::ctype<wchar_t> Product: gcc Version: 13.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: kristian.spangsege at gmail dot com Target Milestone: --- Created attachment 58451 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58451&action=edit test.cpp Demonstrate the bug On Cygwin, a space character is reported as non-printable by `std::ctype<wchar_t>` in the "C" locale (the only locale supported by libstdc+++ on Cygwin). In other words, the following expression evaluates to `false`: ctype.is(std::ctype_base::print, ctype.widen(' ')) where `ctype` is obtained by `std::use_facet<std::ctype<wchar_t>>(loc)` and `loc` is the "C" locale. It should have been evaluated to `true` because a space character is required by the C++ standard to be categorized as printable (the defining distinction between a printable and a graphical character is that space is printable but not graphical). Also, the space character is reported as printable by `std::iswprint(int ch)`. So it seems like the problem is specific to `libstdc++`. Also, the non-wide space character is reported as printable, i.e, `std::use_facet<std::ctype<char>>(loc)::is(std::ctype_base::print, ' ')` is `true`. Also, `ctype.is(std::ctype_base::print, ctype.widen(' '))` is `true` with MinGW, with GCC on Linux, and with Visual Studio. The problem can be demonstrated with the code below (attached as `test.cpp`) in regular Cygwin (https://cygwin.com/install.html) using GCC 12.3.1 and in the Cygwin environment of MSYS2 (https://www.msys2.org/) using GCC 13.2.0: #include <cwctype> #include <string> #include <locale> #include <iostream> int main() { using facet_type = std::ctype<wchar_t>; std::locale loc; const auto& ctype = std::use_facet<facet_type>(loc); wchar_t ch = ctype.widen(' '); std::cout << ctype.is(ctype.print, ch) << "\n"; std::cout << (std::iswprint(std::char_traits<wchar_t>::to_int_type(ch)) != 0) << "\n"; }