https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126111

            Bug ID: 126111
           Summary: std module unconditionally exports wchar_t-related
                    names when configured with --disable-wchar_t
           Product: gcc
           Version: 16.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sebastian.jude at st dot ovgu.de
  Target Milestone: ---

When building libstdc++ configured with --disable-wchar_t, the std module
(std.cc) fails to compile because it unconditionally exports wchar_t-based
types and functions (std::wstring, std::wcout, std::wformat_args, etc.) without
checking whether wchar_t support is actually available.

This leads to multiple compilation errors similar to this:
std.cc: At global scope:
std.cc:1371:14: error: 'make_wformat_args' has not been declared in 'std'
 1371 |   using std::make_wformat_args;
      |              ^~~~~~~~~~~~~~~~~

Expected behavior:
The std module should conditionally export wchar_t-related symbols only when
_GLIBCXX_USE_WCHAR_T is defined.

Tested with GCC 16.1.0 and verified this is likely also present in current
master 
(https://gcc.gnu.org/cgit/gcc/tree/libstdc++-v3/src/c++23/std.cc.in?id=9c36ceaacc080a70f3f664a2eb5f9b32227f5cf5)
as i have not seen any #ifdef guards there either.

Suggested fix:
This is likely very similar to PR118177 - add #ifdef _GLIBCXX_USE_WCHAR_T
guards around all wchar_t-related using declarations in
libstdc++-v3/src/c++23/std.cc.in.

Additional context:
The fallback logic added in PR124268 (if ! ... then ... fi in the Makefile)
currently masks this issue. This means users of --disable-wchar_t see a
successful build, but get an empty std module.

Reply via email to