diff -Naurd mpfr-3.1.5-a/PATCHES mpfr-3.1.5-b/PATCHES
--- mpfr-3.1.5-a/PATCHES	2017-06-06 20:17:02.489704106 +0000
+++ mpfr-3.1.5-b/PATCHES	2017-06-06 20:17:02.513703814 +0000
@@ -0,0 +1 @@
+printf-errno
diff -Naurd mpfr-3.1.5-a/VERSION mpfr-3.1.5-b/VERSION
--- mpfr-3.1.5-a/VERSION	2017-06-06 19:57:01.971909970 +0000
+++ mpfr-3.1.5-b/VERSION	2017-06-06 20:17:02.513703814 +0000
@@ -1 +1 @@
-3.1.5-p5
+3.1.5-p6
diff -Naurd mpfr-3.1.5-a/src/mpfr.h mpfr-3.1.5-b/src/mpfr.h
--- mpfr-3.1.5-a/src/mpfr.h	2017-06-06 19:57:01.971909970 +0000
+++ mpfr-3.1.5-b/src/mpfr.h	2017-06-06 20:17:02.513703814 +0000
@@ -27,7 +27,7 @@
 #define MPFR_VERSION_MAJOR 3
 #define MPFR_VERSION_MINOR 1
 #define MPFR_VERSION_PATCHLEVEL 5
-#define MPFR_VERSION_STRING "3.1.5-p5"
+#define MPFR_VERSION_STRING "3.1.5-p6"
 
 /* Macros dealing with MPFR VERSION */
 #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
diff -Naurd mpfr-3.1.5-a/src/printf.c mpfr-3.1.5-b/src/printf.c
--- mpfr-3.1.5-a/src/printf.c	2016-09-27 07:58:15.000000000 +0000
+++ mpfr-3.1.5-b/src/printf.c	2017-06-06 20:17:02.501703960 +0000
@@ -40,7 +40,6 @@
 # endif /* HAVE___VA_COPY */
 #endif /* HAVE_VA_COPY */
 
-#include <errno.h>
 #include "mpfr-impl.h"
 
 #ifdef _MPFR_H_HAVE_FILE
diff -Naurd mpfr-3.1.5-a/src/vasprintf.c mpfr-3.1.5-b/src/vasprintf.c
--- mpfr-3.1.5-a/src/vasprintf.c	2017-06-06 19:57:01.963910062 +0000
+++ mpfr-3.1.5-b/src/vasprintf.c	2017-06-06 20:17:02.501703960 +0000
@@ -52,6 +52,8 @@
 #include <stddef.h>             /* for ptrdiff_t */
 #endif
 
+#include <errno.h>
+
 #define MPFR_NEED_LONGLONG_H
 #include "mpfr-intmax.h"
 #include "mpfr-impl.h"
diff -Naurd mpfr-3.1.5-a/src/version.c mpfr-3.1.5-b/src/version.c
--- mpfr-3.1.5-a/src/version.c	2017-06-06 19:57:01.971909970 +0000
+++ mpfr-3.1.5-b/src/version.c	2017-06-06 20:17:02.513703814 +0000
@@ -25,5 +25,5 @@
 const char *
 mpfr_get_version (void)
 {
-  return "3.1.5-p5";
+  return "3.1.5-p6";
 }
diff -Naurd mpfr-3.1.5-a/tests/tprintf.c mpfr-3.1.5-b/tests/tprintf.c
--- mpfr-3.1.5-a/tests/tprintf.c	2016-09-27 07:58:14.000000000 +0000
+++ mpfr-3.1.5-b/tests/tprintf.c	2017-06-06 20:17:02.501703960 +0000
@@ -26,6 +26,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <stddef.h>
+#include <errno.h>
 
 #include "mpfr-intmax.h"
 #include "mpfr-test.h"
@@ -109,6 +110,33 @@
 }
 
 static void
+check_vprintf_overflow (const char *fmt, ...)
+{
+  va_list ap;
+  int r, e;
+
+  va_start (ap, fmt);
+  errno = 0;
+  r = mpfr_vprintf (fmt, ap);
+  e = errno;
+  va_end (ap);
+
+  if (r != -1
+#ifdef EOVERFLOW
+      || e != EOVERFLOW
+#endif
+      )
+    {
+      putchar ('\n');
+      fprintf (stderr, "Error in mpfr_vprintf(\"%s\", ...)\n"
+               "Got r = %d, errno = %d\n", fmt, r, e);
+      exit (1);
+    }
+
+  putchar ('\n');
+}
+
+static void
 check_invalid_format (void)
 {
   int i = 0;
@@ -167,8 +195,8 @@
   mpfr_set_ui (x, 1, MPFR_RNDN);
   mpfr_nextabove (x);
 
-  check_vprintf_failure ("%Rb", x);
-  check_vprintf_failure ("%RA %RA %Ra %Ra", x, x, x, x);
+  check_vprintf_overflow ("%Rb", x);
+  check_vprintf_overflow ("%RA %RA %Ra %Ra", x, x, x, x);
 
   mpfr_clear (x);
 }
