https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98725
Bug ID: 98725 Summary: Review what is disabled in libstdc++ by --disable-wchar_t Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Target Milestone: --- Currently libstdc++ guards *any* use of wchar_t with a check for _GLIBCXX_USE_WCHAR_T. This has unfortunate consequences such as std::wstring_convert being unusable to convert between char and char16_t (which doesn't use wchar_t at all). That's because we do this in <bits/locale_conv.h>: #ifdef _GLIBCXX_USE_WCHAR_T _GLIBCXX_BEGIN_NAMESPACE_CXX11 /// String conversions template<typename _Codecvt, typename _Elem = wchar_t, typename _Wide_alloc = allocator<_Elem>, typename _Byte_alloc = allocator<char>> class wstring_convert The wchar_t type exists unconditionally for C++, so traits like std::is_integral_v<wchar_t> are already always defined as true. std::char_traits<wchar_t> also works, by using the primary template (which works for any character-like type). That means that even std::wstring works, albeit slower than if we had optimized support for <wchar.h> in libc. The consequences of --disable-wchar_t (whether implicit or explicit) should to disable explicit instantiations for std::wstring, std::wifstream etc. and to disable wchar_t support in locales and std::filesystem. It doesn't need to disable everything that refers to wchar_t.