This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/77459] [6/7 Regression] undefined reference to `snprintf' when building mingw-w64 cross-compiler
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 27 Sep 2016 13:12:19 +0000
- Subject: [Bug libstdc++/77459] [6/7 Regression] undefined reference to `snprintf' when building mingw-w64 cross-compiler
- Auto-submitted: auto-generated
- References: <bug-77459-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77459
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Does this help?
--- a/libstdc++-v3/src/c++11/debug.cc
+++ b/libstdc++-v3/src/c++11/debug.cc
@@ -540,10 +540,25 @@ namespace
using _Error_formatter = __gnu_debug::_Error_formatter;
using _Parameter = __gnu_debug::_Error_formatter::_Parameter;
+#ifdef _GLIBCXX_USE_C99_STDIO
template<typename _Tp>
int
format_word(char* buf, int n, const char* fmt, _Tp s)
{ return std::min(__builtin_snprintf(buf, n, fmt, s), n - 1); }
+#else
+ int
+ format_word(char* buf, int n, const char* fmt, const char* s)
+ {
+ if ((int)__builtin_strlen(s) >= n)
+ s = "???";
+ return std::min(__builtin_sprintf(buf, fmt, s), n - 1);
+ }
+
+ template<typename _Tp>
+ int
+ format_word(char* buf, int n, const char* fmt, _Tp s)
+ { return std::min(__builtin_sprintf(buf, fmt, s), n - 1); }
+#endif
void
get_max_length(std::size_t& max_length)