On Thu, 14 Jan 2021, 22:22 Alexandre Oliva, <ol...@adacore.com> wrote:
> On Jan 14, 2021, Jonathan Wakely <jwak...@redhat.com> wrote: > > > The problem is that <bits/locale_conv.h> uses wchar_t in default > > template arguments: > > > I think we should fix the header, not disable tests that don't use > > that default template argument. The attached patch should allow you to > > use wstring_convert and wbuffer_convert without wchar_t support. The > > tests which instantiate it with char16_t or char32_t instead of > > wchar_t should work with this patch, right? > > Thanks, I'll give it a spin. That said, ... > > > <aside> > > Is it the case that the wchar_t type is defined on this target, it's > > just that libc doesn't have support for wcslen etc? > > ... it is definitely the case that the target currently defines wchar_t, > and it even offers wchar.h and a lot of (maybe all?) wcs* functions. > This was likely not the case when the patch was first written. > > I'll double check whether any of the patch is still needed for current > versions. > > I figured it would a waste to just discard Corentin's identification of > testcases that failed when glibc wchar_t support was not enabled. > Definitely not a waste, as it's led to this discussion and plan for improvement. > This also means that the test results I'm going to get are likely to not > reflect the conditions for which these patches were originally written. > > > FWIW, I like very much the notion of offering a fallback wchar_t > implementation within libstdc++-v3, so that users get the expected C++ > functionality even when libc doesn't offer it. Even a (conditional?) > typedef to introduce wchar_t could be there. > > Perhaps the test that sets or clears _GLIBCXX_USE_WCHAR_T should be used > to decide whether or not to offer a wchar.h header in libstdc++, and > then (pipe dream?) all other uses of this macro would be just gone? > That would be great. We might be able to get close even if not all the way there. However, some small embedded systems might not want the extra symbols for explicit instantiations of std::wstring, std::wistream in libstdc++.so so we might want a way to suppress them (they could still instantiate those templates implicitly by using them, we just wouldn't have them pre-instantiated in the library). Anyway, let's start just by making wstring_convert usable without wchar_t.