PATCH: Don't unconditionally use snprintf() in libgfortran (PR libfortran/32345)

Rainer Orth ro@techfak.uni-bielefeld.de
Thu Jun 14 16:47:00 GMT 2007


As described in the PR, all gfortran execute tests fail since libgfortran
uses snprintf() unconditionally in one place, but the platform libc lacks
it.  The following patch fixes it: a libgfortran rebuild and retest are in
progress, but the first execute tests pass as expected.

Ok for mainline if it passes?  I think this almost qualifies as obvious.
The 4.2 branch doesn't have backtrace.c and is thus unaffected.

	Rainer

-----------------------------------------------------------------------------
Rainer Orth, Faculty of Technology, Bielefeld University


Thu Jun 14 18:27:54 2007  Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>

	PR libfortran/32345
	* runtime/backtrace.c (show_backtrace): Only use snprintf if
	available.

Index: libgfortran/runtime/backtrace.c
===================================================================
--- libgfortran/runtime/backtrace.c	(revision 125646)
+++ libgfortran/runtime/backtrace.c	(working copy)
@@ -301,7 +301,11 @@ fallback:
 
 	st_printf ("\nBacktrace for this error:\n");
 	arg[0] = (char *) "pstack";
+#ifdef HAVE_SNPRINTF
 	snprintf (buf, sizeof(buf), "%d", (int) getppid ());
+#else
+	sprintf (buf, "%d", (int) getppid ());
+#endif
 	arg[1] = buf;
 	arg[2] = NULL;
 	execvp (arg[0], arg);



More information about the Fortran mailing list