When attempting a bootstrap including libstdc++-v3, the following error will be encountered. libtool: compile: /mingw/src/gccf/./gcc/xgcc -shared-libgcc -B/mingw/src/gccf/./gcc -nostdinc++ -L/mingw/src/gccf/i386-pc-mingw32/libstdc++-v3/src -L/mingw/src/gccf/i386-pc-mingw32/libstdc++-v3/src/.libs -L/mingw/src/gccf/i386-pc-mingw32/winsup/mingw -L/mingw/src/gccf/i386-pc-mingw32/winsup/w32api/lib -isystem /mingw/src/svn/winsup/mingw/include -isystem /mingw/src/svn/winsup/w32api/include -B/mingw/i386-pc-mingw32/bin/ -B/mingw/i386-pc-mingw32/lib/ -isystem /mingw/i386-pc-mingw32/include -isystem /mingw/i386-pc-mingw32/sys-include -I/mingw/src/gccf/i386-pc-mingw32/libstdc++-v3/include/i386-pc-mingw32 -I/mingw/src/gccf/i386-pc-mingw32/libstdc++-v3/include -I/mingw/src/svn/libstdc++-v3/libsupc++ -fno-implicit-templates -Wall -Wextra -Wwrite-strings -Wcast-qual -fdiagnostics-show-location=once -ffunction-sections -fdata-sections -g -O2 -std=gnu++0x -c ../../../../svn/libstdc++-v3/src/functexcept.cc -DDLL_EXPORT -DPIC -o .libs/functexcept.o In file included from /mingw/src/gccf/i386-pc-mingw32/libstdc++-v3/include/string:58, from /mingw/src/gccf/i386-pc-mingw32/libstdc++-v3/include/stdexcept:44, from ../../../../svn/libstdc++-v3/src/functexcept.cc:31: /mingw/src/gccf/i386-pc-mingw32/libstdc++-v3/include/bits/basic_string.h: In function 'std::wstring std::to_wstring(long long int)': /mingw/src/gccf/i386-pc-mingw32/libstdc++-v3/include/bits/basic_string.h:2675: error: no matching function for call to '__to_xstring(int (*)(wchar_t*, const wchar_t*, char*), unsigned int, const wchar_t [5], long long int&)' /mingw/src/gccf/i386-pc-mingw32/libstdc++-v3/include/bits/basic_string.h: In function 'std::wstring std::to_wstring(long long unsigned int)': /mingw/src/gccf/i386-pc-mingw32/libstdc++-v3/include/bits/basic_string.h:2681: error: no matching function for call to '__to_xstring(int (*)(wchar_t*, const wchar_t*, char*), unsigned int, const wchar_t [5], long long unsigned int&)' /mingw/src/gccf/i386-pc-mingw32/libstdc++-v3/include/bits/basic_string.h: In function 'std::wstring std::to_wstring(long double)': /mingw/src/gccf/i386-pc-mingw32/libstdc++-v3/include/bits/basic_string.h:2689: error: no matching function for call to '__to_xstring(int (*)(wchar_t*, const wchar_t*, char*), const int&, const wchar_t [4], long double&)' make[4]: *** [functexcept.lo] Error 1 The problem is that MSVCRT's prototype for vswprintf is incorrect, and differs from the standard C version. This may not be easy to fix in mingwrt. However, the _vsnwprintf function has the correct prototype and works with __to_xstring. I guess the solution is to make libstdc++ use _vsnwprintf instead of vswprintf on *-mingw32.
> > I guess the solution is to make libstdc++ use _vsnwprintf instead of vswprintf > on *-mingw32. > I think that is the most expedient solution. Would an inline redirection of vswprintf to _vsnwprintf in config/os/mingw32/os_define.h (later, if it gets fixed in mingw runtime that could be made conditional on mingw version) work? Danny
I think Danny's solution should work. The inline redirection would live in namespace std, and os_defines.h would also define something like _GLIBCXX_HAVE_BROKEN_VSWPRINTF which would be used in include/*/cwchar to not import the broken function as-is from the global namespace to namespace std. In principle, this brokeness can be easily detected at configure-time and we could (should!) add a separate check for vswprintf, on the parameters too, in GLIBCXX_ENABLE_WCHAR_T, following a strategy similar to the separate checks we have in GLIBCXX_ENABLE_C99. But then, I'm not sure what do with it, if we use it in include/*/cwchar to not import the broken function as-is in namespace std, then the function will disappear also for targets not providing a replacement, as mingw will do... Opinions about this? Is it likely, bound to be a big problem? Because I'd rather prefer having the configure-time check.
Well, in principle the automatic configure-time check could define a _GLIBCXX_HAVE_CONFORMING_VSWPRINTF, checking the parameters too, and then os_defines.h could define a _GLIBCXX_HAVE_REPLACEMENT_VSWPRINTF. Then, include/*/cwchar could guard the import with something like: #if defined(_GLIBCXX_HAVE_CONFORMING_VSWPRINTF) || !defined(_GLIBCXX_HAVE_REPLACEMENT_VSWPRINTF) ... import #endif Anyway, if you can do and test somehow the mingw specific bits in os_defines.h, I can do the rest.
Paolo, I'll give it a try and if I can't get the configury to work for me, I'll let you do that part.
Great, the configury should be in fact pretty easy.
Any progress?
Ok, I will just implement for now the minimal fix: _GLIBCXX_HAVE_BROKEN_VSWPRINTF defined in config/os/mingw32/os_define.h and used in basic_string.h
Subject: Bug 37522 Author: paolo Date: Mon Oct 27 15:01:28 2008 New Revision: 141382 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=141382 Log: 2008-10-27 Paolo Carlini <paolo.carlini@oracle.com> PR libstdc++/37522 * config/os/mingw32/os_defines.h: Define _GLIBCXX_HAVE_BROKEN_VSWPRINTF * include/bits/basic_string.h: Guard string conversions with !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF) too. * testsuite/lib/libstdc++.exp (check_v3_target_string_conversions): New. * testsuite/lib/dg-options.exp (dg-require-string-conversions): New. * testsuite/21_strings/basic_string/numeric_conversions/char/stof.cc: Use the latter. * testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/char/ stoull.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/char/ to_string.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc: Likewise. Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/config/os/mingw32/os_defines.h trunk/libstdc++-v3/include/bits/basic_string.h trunk/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc trunk/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stof.cc trunk/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc trunk/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc trunk/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc trunk/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc trunk/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc trunk/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoull.cc trunk/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/to_string.cc trunk/libstdc++-v3/testsuite/lib/dg-options.exp trunk/libstdc++-v3/testsuite/lib/libstdc++.exp
Fixed.
Hello, I know this bug is fixed since a long time, but there is the same problem when trying to compile the gcc-4.8-20130106.tar.bz2 tarball for mingw-w64. Same prolems having, usually same issues, adding the line // See libstdc++/37522. #define _GLIBCXX_HAVE_BROKEN_VSWPRINTF 1 in the libstdc++-v3/config/os/mingw32-w64/os_defines.h file seems to allow the build. Should i open a new bug, or can you take it in acount from here?
(In reply to comment #10) > Hello, > > I know this bug is fixed since a long time, but there is the same problem when > trying to compile the gcc-4.8-20130106.tar.bz2 tarball for mingw-w64. > > Same prolems having, usually same issues, adding the line > > // See libstdc++/37522. > #define _GLIBCXX_HAVE_BROKEN_VSWPRINTF 1 > in the libstdc++-v3/config/os/mingw32-w64/os_defines.h file seems to allow the > build. > > Should i open a new bug, or can you take it in acount from here? Don't open an new bug, don't reopen this bug. I assume you are using none-trunk version of mingw-w64, are you? If so, please switch to trunk-version.
(In reply to comment #11) > Don't open an new bug, don't reopen this bug. I assume you are using > none-trunk version of mingw-w64, are you? If so, please switch to > trunk-version. i'm using the version taken at http://sourceforge.net/projects/mingw-w64/files/mingw-w64/mingw-w64-release/mingw-w64-v2.0.7.tar.gz/download . I think it is the trunk version, isn't it?
(In reply to comment #12) > (In reply to comment #11) > > > Don't open an new bug, don't reopen this bug. I assume you are using > > none-trunk version of mingw-w64, are you? If so, please switch to > > trunk-version. > > i'm using the version taken at > http://sourceforge.net/projects/mingw-w64/files/mingw-w64/mingw-w64-release/mingw-w64-v2.0.7.tar.gz/download > . > > I think it is the trunk version, isn't it? No, it isn't. It is v2.x branch as written even in file-name. But please stop using gcc-bugreports to get answered your user-questions. Use mingw-w64's mailing-list instead.
(In reply to comment #11) > Don't open an new bug, don't reopen this bug. I assume you are using > none-trunk version of mingw-w64, are you? If so, please switch to > trunk-version. When exactly was this fixed on the trunk? The mingw32-headers package on Fedora 17 (2.0.999-0.8.trunk.20121016) still has this issue. (In reply to comment #13) > No, it isn't. It is v2.x branch as written even in file-name. But please stop > using gcc-bugreports to get answered your user-questions. Use mingw-w64's > mailing-list instead. Often GCC works around problems with older versions of other tools; it seems reasonable to me to do the same in this case, especially since there isn't yet a release with this issue fixed.
Issue was fixed on trunk. As far as I know should rawhide Fedora have fixed that issue already. Nevertheless we could define the broken-vsprintf macro based on header-version. I will come up with a patch for that.
Header version could be detected in _mingw_mac.h for MinGW-w64 or in _mingw.h for MinGW32. _mingw.h could be used for MinGW-w64 too as it include internally _mingw_mac.h.
Created attachment 29582 [details] Proposed patch Possible patch for latest MinGW-w64. Patched GCC version: 4.7.2 Can be easy edited for trunk version. --- ./libstdc++-v3/config/os/mingw32-w64/os_defines.h.orig 2011-12-23 21:23:38 +0400 +++ ./libstdc++-v3/config/os/mingw32-w64/os_defines.h 2013-03-05 05:22:07 +0400 @@ -64,7 +64,10 @@ #define _GLIBCXX_HAVE_DOS_BASED_FILESYSTEM 1 // See libstdc++/37522. +#include <_mingw_mac.h> +#if !defined (__MINGW64_VERSION_MAJOR) || (__MINGW64_VERSION_MAJOR < 3) #define _GLIBCXX_HAVE_BROKEN_VSWPRINTF 1 +#endif // See libstdc++/43738 // On native windows targets there is no ioctl function. And the existing
Author: redi Date: Mon Dec 22 16:41:39 2014 New Revision: 219019 URL: https://gcc.gnu.org/viewcvs?rev=219019&root=gcc&view=rev Log: PR libstdc++/37522 * include/bits/basic_string.h (stod, stof, stoi, stol, stold, stoll, stoul, stoull, to_string): Only use _GLIBCXX_HAVE_BROKEN_VSWPRINTF to guard definition of to_wstring. * testsuite/21_strings/basic_string/numeric_conversions/char/dr1261.cc: Do not use dg-require-string-conversions. * testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/char/stof.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/char/ stoull.cc: Likewise. * testsuite/21_strings/basic_string/numeric_conversions/char/ to_string.cc: Likewise. Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/include/bits/basic_string.h trunk/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/dr1261.cc trunk/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc trunk/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stof.cc trunk/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc trunk/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc trunk/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc trunk/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc trunk/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc trunk/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoull.cc trunk/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/to_string.cc
Author: redi Date: Thu May 28 16:27:46 2015 New Revision: 223840 URL: https://gcc.gnu.org/viewcvs?rev=223840&root=gcc&view=rev Log: Backport from mainline 2014-12-22 Jonathan Wakely <jwakely@redhat.com> PR libstdc++/37522 * include/bits/basic_string.h (stod, stof, stoi, stol, stold, stoll, stoul, stoull, to_string): Only use _GLIBCXX_HAVE_BROKEN_VSWPRINTF to guard definition of to_wstring. Modified: branches/gcc-4_9-branch/libstdc++-v3/ChangeLog branches/gcc-4_9-branch/libstdc++-v3/include/bits/basic_string.h