On Tue, 14 Jul 2026, 08:21 Jonathan Wakely, <[email protected]> wrote:

>
>
> On Tue, 14 Jul 2026, 08:15 Tomasz Kaminski, <[email protected]> wrote:
>
>>
>>
>> On Mon, Jul 13, 2026 at 7:15 PM Jonathan Wakely <[email protected]>
>> wrote:
>>
>>> We should not try to export names which are not declared if GCC is
>>> configured with --disable-wchar_t.
>>>
>>> We should also not define the wide stream aliases in <syncstream> and
>>> <spanstream>.
>>>
>>> libstdc++-v3/ChangeLog:
>>>
>>>         PR libstdc++/126111
>>>         * include/std/format (__format::__write_escape_seq): Move alias
>>>         declaration into #ifdef _GLIBCXX_USE_WCHAR_T group.
>>>         * include/std/spanstream (wspanbuf, wispanstream, wospanstream)
>>>         (wspanstream): Only declare for _GLIBCXX_USE_WCHAR_T.
>>>         * include/std/syncstream (wsyncbuf wosyncstream): Likewise.
>>>         * src/c++23/std.cc.in: Add preprocessor checks for
>>>         _GLIBCXX_USE_WCHAR_T to names which depend on it.
>>> ---
>>>
>>> Tested x86_64-linux.
>>>
>> Outside of single question below, this LGTM.
>>
>>>
>>>  libstdc++-v3/include/std/format     |  2 +-
>>>  libstdc++-v3/include/std/spanstream |  8 ++++++
>>>  libstdc++-v3/include/std/syncstream |  5 ++--
>>>  libstdc++-v3/src/c++23/std.cc.in    | 44 ++++++++++++++++++++++++-----
>>>  4 files changed, 49 insertions(+), 10 deletions(-)
>>>
>>> diff --git a/libstdc++-v3/include/std/format
>>> b/libstdc++-v3/include/std/format
>>> index 1b4082e07a44..2530ecb58057 100644
>>> --- a/libstdc++-v3/include/std/format
>>> +++ b/libstdc++-v3/include/std/format
>>> @@ -1052,7 +1052,6 @@ namespace __format
>>>      __write_escape_seq(_Out __out, uint_least32_t __val,
>>>                        basic_string_view<_CharT> __prefix)
>>>      {
>>> -      using _Str_view = basic_string_view<_CharT>;
>>>
>> Why do we need this change? The function should not be instantiated
>> with _CharT = wchar_t, so this should be OK.
>>
>
> Because it gives a -Wunused-local-typedef warning when the WCHAR_T macro
> is undefined.
>

I'll change it to wstring_view.




>
>        constexpr size_t __max = 8;
>>>        char __buf[__max];
>>>        const string_view __narrow(
>>> @@ -1067,6 +1066,7 @@ namespace __format
>>>  #ifdef _GLIBCXX_USE_WCHAR_T
>>>        else
>>>         {
>>> +         using _Str_view = basic_string_view<_CharT>;
>>>
>> If we go with this direction, simply replace _CharT with wchar_t
>> in line below, and _Str_view with wstring_view in __format_write.
>>
>>>           _CharT __wbuf[__max];
>>>           const size_t __n = __narrow.size();
>>>           std::__to_wstring_numeric(__narrow.data(), __n, __wbuf);
>>> diff --git a/libstdc++-v3/include/std/spanstream
>>> b/libstdc++-v3/include/std/spanstream
>>> index fd2a446ddaa3..6f1f681ae793 100644
>>> --- a/libstdc++-v3/include/std/spanstream
>>> +++ b/libstdc++-v3/include/std/spanstream
>>> @@ -225,7 +225,9 @@ template<typename _CharT, typename _Traits>
>>>    { __x.swap(__y); }
>>>
>>>  using spanbuf = basic_spanbuf<char>;
>>> +#ifdef _GLIBCXX_USE_WCHAR_T
>>>  using wspanbuf = basic_spanbuf<wchar_t>;
>>> +#endif
>>>
>>>  template<typename _CharT, typename _Traits>
>>>    class basic_ispanstream
>>> @@ -319,7 +321,9 @@ template<typename _CharT, typename _Traits>
>>>    { __x.swap(__y); }
>>>
>>>  using ispanstream = basic_ispanstream<char>;
>>> +#ifdef _GLIBCXX_USE_WCHAR_T
>>>  using wispanstream = basic_ispanstream<wchar_t>;
>>> +#endif
>>>
>>>  template<typename _CharT, typename _Traits>
>>>    class basic_ospanstream
>>> @@ -389,7 +393,9 @@ template<typename _CharT, typename _Traits>
>>>    { __x.swap(__y); }
>>>
>>>  using ospanstream = basic_ospanstream<char>;
>>> +#ifdef _GLIBCXX_USE_WCHAR_T
>>>  using wospanstream = basic_ospanstream<wchar_t>;
>>> +#endif
>>>
>>>  template<typename _CharT, typename _Traits>
>>>    class basic_spanstream
>>> @@ -459,7 +465,9 @@ template<typename _CharT, typename _Traits>
>>>    { __x.swap(__y); }
>>>
>>>  using spanstream = basic_spanstream<char>;
>>> +#ifdef _GLIBCXX_USE_WCHAR_T
>>>  using wspanstream = basic_spanstream<wchar_t>;
>>> +#endif
>>>
>>>  _GLIBCXX_END_NAMESPACE_VERSION
>>>  } // namespace std
>>> diff --git a/libstdc++-v3/include/std/syncstream
>>> b/libstdc++-v3/include/std/syncstream
>>> index 9cecd513e9a5..7a1f956dca55 100644
>>> --- a/libstdc++-v3/include/std/syncstream
>>> +++ b/libstdc++-v3/include/std/syncstream
>>> @@ -299,10 +299,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>>>      { __x.swap(__y); }
>>>
>>>    using syncbuf = basic_syncbuf<char>;
>>> -  using wsyncbuf = basic_syncbuf<wchar_t>;
>>> -
>>>    using osyncstream = basic_osyncstream<char>;
>>> +#ifdef _GLIBCXX_USE_WCHAR_T
>>> +  using wsyncbuf = basic_syncbuf<wchar_t>;
>>>    using wosyncstream = basic_osyncstream<wchar_t>;
>>> +#endif
>>>  _GLIBCXX_END_NAMESPACE_VERSION
>>>  } // namespace std
>>>  #endif // __cpp_lib_syncbuf
>>> diff --git a/libstdc++-v3/src/c++23/std.cc.in b/libstdc++-v3/src/c++23/
>>> std.cc.in
>>> index dbed0112dca5..5aab08f2c498 100644
>>> --- a/libstdc++-v3/src/c++23/std.cc.in
>>> +++ b/libstdc++-v3/src/c++23/std.cc.in
>>> @@ -1368,17 +1368,19 @@ export namespace std
>>>  #endif
>>>    using std::formatter;
>>>    using std::make_format_args;
>>> -  using std::make_wformat_args;
>>>  #if __cpp_lib_format >= 202603L // >= C++26
>>>    using std::dynamic_format;
>>>  #endif
>>>    using std::vformat;
>>>    using std::vformat_to;
>>>    using std::visit_format_arg;
>>> +#ifdef _GLIBCXX_USE_WCHAR_T
>>> +  using std::make_wformat_args;
>>>    using std::wformat_args;
>>>    using std::wformat_context;
>>>    using std::wformat_parse_context;
>>>    using std::wformat_string;
>>> +#endif
>>>  #ifdef __cpp_lib_format_ranges
>>>    using std::format_kind;
>>>    using std::range_format;
>>> @@ -1416,10 +1418,12 @@ export namespace std
>>>    using std::ifstream;
>>>    using std::ofstream;
>>>    using std::swap;
>>> +#ifdef _GLIBCXX_USE_WCHAR_T
>>>    using std::wfilebuf;
>>>    using std::wfstream;
>>>    using std::wifstream;
>>>    using std::wofstream;
>>> +#endif
>>>  }
>>>
>>>  // <functional>
>>> @@ -1620,7 +1624,9 @@ export namespace std
>>>    using std::streamsize;
>>>    using std::unitbuf;
>>>    using std::uppercase;
>>> +#ifdef _GLIBCXX_USE_WCHAR_T
>>>    using std::wios;
>>> +#endif
>>>  }
>>>
>>>  // <iosfwd>
>>> @@ -1639,9 +1645,11 @@ export namespace std
>>>    using std::basic_syncbuf;
>>>    using std::osyncstream;
>>>    using std::syncbuf;
>>> +#ifdef _GLIBCXX_USE_WCHAR_T
>>>    using std::wosyncstream;
>>>    using std::wsyncbuf;
>>>  #endif
>>> +#endif
>>>  }
>>>
>>>  // <iostream>
>>> @@ -1651,10 +1659,12 @@ export namespace std
>>>    using std::cin;
>>>    using std::clog;
>>>    using std::cout;
>>> +#ifdef _GLIBCXX_USE_WCHAR_T
>>>    using std::wcerr;
>>>    using std::wcin;
>>>    using std::wclog;
>>>    using std::wcout;
>>> +#endif
>>>  }
>>>
>>>  // <istream>
>>> @@ -1664,8 +1674,10 @@ export namespace std
>>>    using std::basic_istream;
>>>    using std::iostream;
>>>    using std::istream;
>>> +#ifdef _GLIBCXX_USE_WCHAR_T
>>>    using std::wiostream;
>>>    using std::wistream;
>>> +#endif
>>>    using std::ws;
>>>    using std::operator>>;
>>>  }
>>> @@ -2487,7 +2499,9 @@ export namespace std
>>>    using std::ends;
>>>    using std::flush;
>>>    using std::ostream;
>>> +#ifdef _GLIBCXX_USE_WCHAR_T
>>>    using std::wostream;
>>> +#endif
>>>    using std::operator<<;
>>>  #ifdef __cpp_lib_syncbuf
>>>    using std::emit_on_flush;
>>> @@ -2916,9 +2930,11 @@ export namespace std
>>>    using std::ssub_match;
>>>    using std::sub_match;
>>>    using std::swap;
>>> +#ifdef _GLIBCXX_USE_WCHAR_T
>>>    using std::wcsub_match;
>>>    using std::wregex;
>>>    using std::wssub_match;
>>> +#endif
>>>    using std::operator==;
>>>    using std::operator<=>;
>>>    using std::operator<<;
>>> @@ -2934,20 +2950,24 @@ export namespace std
>>>    using std::smatch;
>>>    using std::sregex_iterator;
>>>    using std::sregex_token_iterator;
>>> +#ifdef _GLIBCXX_USE_WCHAR_T
>>>    using std::wcmatch;
>>>    using std::wcregex_iterator;
>>>    using std::wcregex_token_iterator;
>>>    using std::wsmatch;
>>>    using std::wsregex_iterator;
>>>    using std::wsregex_token_iterator;
>>> +#endif
>>>    namespace pmr
>>>    {
>>>  #if _GLIBCXX_USE_CXX11_ABI
>>>      using std::pmr::cmatch;
>>>      using std::pmr::match_results;
>>>      using std::pmr::smatch;
>>> +#ifdef _GLIBCXX_USE_WCHAR_T
>>>      using std::pmr::wcmatch;
>>>      using std::pmr::wsmatch;
>>> +#endif
>>>  #endif
>>>    }
>>>  }
>>> @@ -3020,17 +3040,19 @@ export namespace std
>>>  export namespace std
>>>  {
>>>    using std::basic_spanbuf;
>>> -  using std::spanbuf;
>>> -  using std::wspanbuf;
>>>    using std::basic_ispanstream;
>>> -  using std::ispanstream;
>>> -  using std::wispanstream;
>>>    using std::basic_ospanstream;
>>> -  using std::ospanstream;
>>> -  using std::wospanstream;
>>>    using std::basic_spanstream;
>>> +  using std::spanbuf;
>>> +  using std::ispanstream;
>>> +  using std::ospanstream;
>>>    using std::spanstream;
>>> +#ifdef _GLIBCXX_USE_WCHAR_T
>>> +  using std::wspanbuf;
>>> +  using std::wispanstream;
>>> +  using std::wospanstream;
>>>    using std::wspanstream;
>>> +#endif
>>>  }
>>>  #endif
>>>
>>> @@ -3046,10 +3068,12 @@ export namespace std
>>>    using std::stringbuf;
>>>    using std::stringstream;
>>>    using std::swap;
>>> +#ifdef _GLIBCXX_USE_WCHAR_T
>>>    using std::wistringstream;
>>>    using std::wostringstream;
>>>    using std::wstringbuf;
>>>    using std::wstringstream;
>>> +#endif
>>>  }
>>>
>>>  // <stack>
>>> @@ -3144,7 +3168,9 @@ export namespace std
>>>  {
>>>    using std::basic_streambuf;
>>>    using std::streambuf;
>>> +#ifdef _GLIBCXX_USE_WCHAR_T
>>>    using std::wstreambuf;
>>> +#endif
>>>  }
>>>
>>>  // <string>
>>> @@ -3171,7 +3197,9 @@ export namespace std
>>>    using std::stoull;
>>>    using std::string;
>>>    using std::to_string;
>>> +#ifdef _GLIBCXX_USE_WCHAR_T
>>>    using std::to_wstring;
>>> +#endif
>>>    using std::u16string;
>>>    using std::u32string;
>>>    using std::u8string;
>>> @@ -3236,9 +3264,11 @@ export namespace std
>>>    using std::basic_osyncstream;
>>>    using std::osyncstream;
>>>    using std::syncbuf;
>>> +#ifdef _GLIBCXX_USE_WCHAR_T
>>>    using std::wosyncstream;
>>>    using std::wsyncbuf;
>>>  #endif
>>> +#endif
>>>  }
>>>
>>>  // 19.5 <system_error>
>>> --
>>> 2.55.0
>>>
>>>

Reply via email to