From ccacefc7a6d38dd4d8b959ed5ed01591fba41f53 Mon Sep 17 00:00:00 2001
From: Thomas Koenig <tkoenig@gcc.gnu.org>
Date: Sun, 13 Jan 2008 22:13:52 +0000
Subject: [PATCH] re PR libfortran/34746 (wrong formats in libgfortran's
 runtime_error)

2008-01-13  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR libfortran/34746
	* m4/iforeach.m4 (name`'rtype_qual`_'atype_code):  Use %ld
	in printf format for all bounds checking; cast all
	integer-like arguments to runtime_error() to long int.
	(`m'name`'rtype_qual`_'atype_code):  Likewise.
	(`s'name`'rtype_qual`_'atype_code):  Likewise.
	* m4/ifunction.m4 (name`'rtype_qual`_'atype_code):  Likewise.
	(`m'name`'rtype_qual`_'atype_code):  Likewise.
	(`s'name`'rtype_qual`_'atype_code):  Likewise.
	* generated/all_l16.c: Regenerated.
	* generated/all_l4.c: Regenerated.
	* generated/all_l8.c: Regenerated.
	* generated/any_l16.c: Regenerated.
	* generated/any_l4.c: Regenerated.
	* generated/any_l8.c: Regenerated.
	* generated/count_16_l16.c: Regenerated.
	* generated/count_16_l4.c: Regenerated.
	* generated/count_16_l8.c: Regenerated.
	* generated/count_4_l16.c: Regenerated.
	* generated/count_4_l4.c: Regenerated.
	* generated/count_4_l8.c: Regenerated.
	* generated/count_8_l16.c: Regenerated.
	* generated/count_8_l4.c: Regenerated.
	* generated/count_8_l8.c: Regenerated.
	* generated/maxloc0_16_i1.c: Regenerated.
	* generated/maxloc0_16_i16.c: Regenerated.
	* generated/maxloc0_16_i2.c: Regenerated.
	* generated/maxloc0_16_i4.c: Regenerated.
	* generated/maxloc0_16_i8.c: Regenerated.
	* generated/maxloc0_16_r10.c: Regenerated.
	* generated/maxloc0_16_r16.c: Regenerated.
	* generated/maxloc0_16_r4.c: Regenerated.
	* generated/maxloc0_16_r8.c: Regenerated.
	* generated/maxloc0_4_i1.c: Regenerated.
	* generated/maxloc0_4_i16.c: Regenerated.
	* generated/maxloc0_4_i2.c: Regenerated.
	* generated/maxloc0_4_i4.c: Regenerated.
	* generated/maxloc0_4_i8.c: Regenerated.
	* generated/maxloc0_4_r10.c: Regenerated.
	* generated/maxloc0_4_r16.c: Regenerated.
	* generated/maxloc0_4_r4.c: Regenerated.
	* generated/maxloc0_4_r8.c: Regenerated.
	* generated/maxloc0_8_i1.c: Regenerated.
	* generated/maxloc0_8_i16.c: Regenerated.
	* generated/maxloc0_8_i2.c: Regenerated.
	* generated/maxloc0_8_i4.c: Regenerated.
	* generated/maxloc0_8_i8.c: Regenerated.
	* generated/maxloc0_8_r10.c: Regenerated.
	* generated/maxloc0_8_r16.c: Regenerated.
	* generated/maxloc0_8_r4.c: Regenerated.
	* generated/maxloc0_8_r8.c: Regenerated.
	* generated/maxloc1_16_i1.c: Regenerated.
	* generated/maxloc1_16_i16.c: Regenerated.
	* generated/maxloc1_16_i2.c: Regenerated.
	* generated/maxloc1_16_i4.c: Regenerated.
	* generated/maxloc1_16_i8.c: Regenerated.
	* generated/maxloc1_16_r10.c: Regenerated.
	* generated/maxloc1_16_r16.c: Regenerated.
	* generated/maxloc1_16_r4.c: Regenerated.
	* generated/maxloc1_16_r8.c: Regenerated.
	* generated/maxloc1_4_i1.c: Regenerated.
	* generated/maxloc1_4_i16.c: Regenerated.
	* generated/maxloc1_4_i2.c: Regenerated.
	* generated/maxloc1_4_i4.c: Regenerated.
	* generated/maxloc1_4_i8.c: Regenerated.
	* generated/maxloc1_4_r10.c: Regenerated.
	* generated/maxloc1_4_r16.c: Regenerated.
	* generated/maxloc1_4_r4.c: Regenerated.
	* generated/maxloc1_4_r8.c: Regenerated.
	* generated/maxloc1_8_i1.c: Regenerated.
	* generated/maxloc1_8_i16.c: Regenerated.
	* generated/maxloc1_8_i2.c: Regenerated.
	* generated/maxloc1_8_i4.c: Regenerated.
	* generated/maxloc1_8_i8.c: Regenerated.
	* generated/maxloc1_8_r10.c: Regenerated.
	* generated/maxloc1_8_r16.c: Regenerated.
	* generated/maxloc1_8_r4.c: Regenerated.
	* generated/maxloc1_8_r8.c: Regenerated.
	* generated/maxval_i1.c: Regenerated.
	* generated/maxval_i16.c: Regenerated.
	* generated/maxval_i2.c: Regenerated.
	* generated/maxval_i4.c: Regenerated.
	* generated/maxval_i8.c: Regenerated.
	* generated/maxval_r10.c: Regenerated.
	* generated/maxval_r16.c: Regenerated.
	* generated/maxval_r4.c: Regenerated.
	* generated/maxval_r8.c: Regenerated.
	* generated/minloc0_16_i1.c: Regenerated.
	* generated/minloc0_16_i16.c: Regenerated.
	* generated/minloc0_16_i2.c: Regenerated.
	* generated/minloc0_16_i4.c: Regenerated.
	* generated/minloc0_16_i8.c: Regenerated.
	* generated/minloc0_16_r10.c: Regenerated.
	* generated/minloc0_16_r16.c: Regenerated.
	* generated/minloc0_16_r4.c: Regenerated.
	* generated/minloc0_16_r8.c: Regenerated.
	* generated/minloc0_4_i1.c: Regenerated.
	* generated/minloc0_4_i16.c: Regenerated.
	* generated/minloc0_4_i2.c: Regenerated.
	* generated/minloc0_4_i4.c: Regenerated.
	* generated/minloc0_4_i8.c: Regenerated.
	* generated/minloc0_4_r10.c: Regenerated.
	* generated/minloc0_4_r16.c: Regenerated.
	* generated/minloc0_4_r4.c: Regenerated.
	* generated/minloc0_4_r8.c: Regenerated.
	* generated/minloc0_8_i1.c: Regenerated.
	* generated/minloc0_8_i16.c: Regenerated.
	* generated/minloc0_8_i2.c: Regenerated.
	* generated/minloc0_8_i4.c: Regenerated.
	* generated/minloc0_8_i8.c: Regenerated.
	* generated/minloc0_8_r10.c: Regenerated.
	* generated/minloc0_8_r16.c: Regenerated.
	* generated/minloc0_8_r4.c: Regenerated.
	* generated/minloc0_8_r8.c: Regenerated.
	* generated/minloc1_16_i1.c: Regenerated.
	* generated/minloc1_16_i16.c: Regenerated.
	* generated/minloc1_16_i2.c: Regenerated.
	* generated/minloc1_16_i4.c: Regenerated.
	* generated/minloc1_16_i8.c: Regenerated.
	* generated/minloc1_16_r10.c: Regenerated.
	* generated/minloc1_16_r16.c: Regenerated.
	* generated/minloc1_16_r4.c: Regenerated.
	* generated/minloc1_16_r8.c: Regenerated.
	* generated/minloc1_4_i1.c: Regenerated.
	* generated/minloc1_4_i16.c: Regenerated.
	* generated/minloc1_4_i2.c: Regenerated.
	* generated/minloc1_4_i4.c: Regenerated.
	* generated/minloc1_4_i8.c: Regenerated.
	* generated/minloc1_4_r10.c: Regenerated.
	* generated/minloc1_4_r16.c: Regenerated.
	* generated/minloc1_4_r4.c: Regenerated.
	* generated/minloc1_4_r8.c: Regenerated.
	* generated/minloc1_8_i1.c: Regenerated.
	* generated/minloc1_8_i16.c: Regenerated.
	* generated/minloc1_8_i2.c: Regenerated.
	* generated/minloc1_8_i4.c: Regenerated.
	* generated/minloc1_8_i8.c: Regenerated.
	* generated/minloc1_8_r10.c: Regenerated.
	* generated/minloc1_8_r16.c: Regenerated.
	* generated/minloc1_8_r4.c: Regenerated.
	* generated/minloc1_8_r8.c: Regenerated.
	* generated/minval_i1.c: Regenerated.
	* generated/minval_i16.c: Regenerated.
	* generated/minval_i2.c: Regenerated.
	* generated/minval_i4.c: Regenerated.
	* generated/minval_i8.c: Regenerated.
	* generated/minval_r10.c: Regenerated.
	* generated/minval_r16.c: Regenerated.
	* generated/minval_r4.c: Regenerated.
	* generated/minval_r8.c: Regenerated.
	* generated/product_c10.c: Regenerated.
	* generated/product_c16.c: Regenerated.
	* generated/product_c4.c: Regenerated.
	* generated/product_c8.c: Regenerated.
	* generated/product_i1.c: Regenerated.
	* generated/product_i16.c: Regenerated.
	* generated/product_i2.c: Regenerated.
	* generated/product_i4.c: Regenerated.
	* generated/product_i8.c: Regenerated.
	* generated/product_r10.c: Regenerated.
	* generated/product_r16.c: Regenerated.
	* generated/product_r4.c: Regenerated.
	* generated/product_r8.c: Regenerated.
	* generated/sum_c10.c: Regenerated.
	* generated/sum_c16.c: Regenerated.
	* generated/sum_c4.c: Regenerated.
	* generated/sum_c8.c: Regenerated.
	* generated/sum_i1.c: Regenerated.
	* generated/sum_i16.c: Regenerated.
	* generated/sum_i2.c: Regenerated.
	* generated/sum_i4.c: Regenerated.
	* generated/sum_i8.c: Regenerated.
	* generated/sum_r10.c: Regenerated.
	* generated/sum_r16.c: Regenerated.
	* generated/sum_r4.c: Regenerated.
	* generated/sum_r8.c: Regenerated.

From-SVN: r131514
---
 libgfortran/ChangeLog                  | 179 +++++++++++++++++++++++++
 libgfortran/generated/all_l16.c        |   9 +-
 libgfortran/generated/all_l4.c         |   9 +-
 libgfortran/generated/all_l8.c         |   9 +-
 libgfortran/generated/any_l16.c        |   9 +-
 libgfortran/generated/any_l4.c         |   9 +-
 libgfortran/generated/any_l8.c         |   9 +-
 libgfortran/generated/count_16_l16.c   |   9 +-
 libgfortran/generated/count_16_l4.c    |   9 +-
 libgfortran/generated/count_16_l8.c    |   9 +-
 libgfortran/generated/count_4_l16.c    |   9 +-
 libgfortran/generated/count_4_l4.c     |   9 +-
 libgfortran/generated/count_4_l8.c     |   9 +-
 libgfortran/generated/count_8_l16.c    |   9 +-
 libgfortran/generated/count_8_l4.c     |   9 +-
 libgfortran/generated/count_8_l8.c     |   9 +-
 libgfortran/generated/maxloc0_16_i1.c  |  21 +--
 libgfortran/generated/maxloc0_16_i16.c |  21 +--
 libgfortran/generated/maxloc0_16_i2.c  |  21 +--
 libgfortran/generated/maxloc0_16_i4.c  |  21 +--
 libgfortran/generated/maxloc0_16_i8.c  |  21 +--
 libgfortran/generated/maxloc0_16_r10.c |  21 +--
 libgfortran/generated/maxloc0_16_r16.c |  21 +--
 libgfortran/generated/maxloc0_16_r4.c  |  21 +--
 libgfortran/generated/maxloc0_16_r8.c  |  21 +--
 libgfortran/generated/maxloc0_4_i1.c   |  21 +--
 libgfortran/generated/maxloc0_4_i16.c  |  21 +--
 libgfortran/generated/maxloc0_4_i2.c   |  21 +--
 libgfortran/generated/maxloc0_4_i4.c   |  21 +--
 libgfortran/generated/maxloc0_4_i8.c   |  21 +--
 libgfortran/generated/maxloc0_4_r10.c  |  21 +--
 libgfortran/generated/maxloc0_4_r16.c  |  21 +--
 libgfortran/generated/maxloc0_4_r4.c   |  21 +--
 libgfortran/generated/maxloc0_4_r8.c   |  21 +--
 libgfortran/generated/maxloc0_8_i1.c   |  21 +--
 libgfortran/generated/maxloc0_8_i16.c  |  21 +--
 libgfortran/generated/maxloc0_8_i2.c   |  21 +--
 libgfortran/generated/maxloc0_8_i4.c   |  21 +--
 libgfortran/generated/maxloc0_8_i8.c   |  21 +--
 libgfortran/generated/maxloc0_8_r10.c  |  21 +--
 libgfortran/generated/maxloc0_8_r16.c  |  21 +--
 libgfortran/generated/maxloc0_8_r4.c   |  21 +--
 libgfortran/generated/maxloc0_8_r8.c   |  21 +--
 libgfortran/generated/maxloc1_16_i1.c  |  19 +--
 libgfortran/generated/maxloc1_16_i16.c |  19 +--
 libgfortran/generated/maxloc1_16_i2.c  |  19 +--
 libgfortran/generated/maxloc1_16_i4.c  |  19 +--
 libgfortran/generated/maxloc1_16_i8.c  |  19 +--
 libgfortran/generated/maxloc1_16_r10.c |  19 +--
 libgfortran/generated/maxloc1_16_r16.c |  19 +--
 libgfortran/generated/maxloc1_16_r4.c  |  19 +--
 libgfortran/generated/maxloc1_16_r8.c  |  19 +--
 libgfortran/generated/maxloc1_4_i1.c   |  19 +--
 libgfortran/generated/maxloc1_4_i16.c  |  19 +--
 libgfortran/generated/maxloc1_4_i2.c   |  19 +--
 libgfortran/generated/maxloc1_4_i4.c   |  19 +--
 libgfortran/generated/maxloc1_4_i8.c   |  19 +--
 libgfortran/generated/maxloc1_4_r10.c  |  19 +--
 libgfortran/generated/maxloc1_4_r16.c  |  19 +--
 libgfortran/generated/maxloc1_4_r4.c   |  19 +--
 libgfortran/generated/maxloc1_4_r8.c   |  19 +--
 libgfortran/generated/maxloc1_8_i1.c   |  19 +--
 libgfortran/generated/maxloc1_8_i16.c  |  19 +--
 libgfortran/generated/maxloc1_8_i2.c   |  19 +--
 libgfortran/generated/maxloc1_8_i4.c   |  19 +--
 libgfortran/generated/maxloc1_8_i8.c   |  19 +--
 libgfortran/generated/maxloc1_8_r10.c  |  19 +--
 libgfortran/generated/maxloc1_8_r16.c  |  19 +--
 libgfortran/generated/maxloc1_8_r4.c   |  19 +--
 libgfortran/generated/maxloc1_8_r8.c   |  19 +--
 libgfortran/generated/maxval_i1.c      |  19 +--
 libgfortran/generated/maxval_i16.c     |  19 +--
 libgfortran/generated/maxval_i2.c      |  19 +--
 libgfortran/generated/maxval_i4.c      |  19 +--
 libgfortran/generated/maxval_i8.c      |  19 +--
 libgfortran/generated/maxval_r10.c     |  19 +--
 libgfortran/generated/maxval_r16.c     |  19 +--
 libgfortran/generated/maxval_r4.c      |  19 +--
 libgfortran/generated/maxval_r8.c      |  19 +--
 libgfortran/generated/minloc0_16_i1.c  |  21 +--
 libgfortran/generated/minloc0_16_i16.c |  21 +--
 libgfortran/generated/minloc0_16_i2.c  |  21 +--
 libgfortran/generated/minloc0_16_i4.c  |  21 +--
 libgfortran/generated/minloc0_16_i8.c  |  21 +--
 libgfortran/generated/minloc0_16_r10.c |  21 +--
 libgfortran/generated/minloc0_16_r16.c |  21 +--
 libgfortran/generated/minloc0_16_r4.c  |  21 +--
 libgfortran/generated/minloc0_16_r8.c  |  21 +--
 libgfortran/generated/minloc0_4_i1.c   |  21 +--
 libgfortran/generated/minloc0_4_i16.c  |  21 +--
 libgfortran/generated/minloc0_4_i2.c   |  21 +--
 libgfortran/generated/minloc0_4_i4.c   |  21 +--
 libgfortran/generated/minloc0_4_i8.c   |  21 +--
 libgfortran/generated/minloc0_4_r10.c  |  21 +--
 libgfortran/generated/minloc0_4_r16.c  |  21 +--
 libgfortran/generated/minloc0_4_r4.c   |  21 +--
 libgfortran/generated/minloc0_4_r8.c   |  21 +--
 libgfortran/generated/minloc0_8_i1.c   |  21 +--
 libgfortran/generated/minloc0_8_i16.c  |  21 +--
 libgfortran/generated/minloc0_8_i2.c   |  21 +--
 libgfortran/generated/minloc0_8_i4.c   |  21 +--
 libgfortran/generated/minloc0_8_i8.c   |  21 +--
 libgfortran/generated/minloc0_8_r10.c  |  21 +--
 libgfortran/generated/minloc0_8_r16.c  |  21 +--
 libgfortran/generated/minloc0_8_r4.c   |  21 +--
 libgfortran/generated/minloc0_8_r8.c   |  21 +--
 libgfortran/generated/minloc1_16_i1.c  |  19 +--
 libgfortran/generated/minloc1_16_i16.c |  19 +--
 libgfortran/generated/minloc1_16_i2.c  |  19 +--
 libgfortran/generated/minloc1_16_i4.c  |  19 +--
 libgfortran/generated/minloc1_16_i8.c  |  19 +--
 libgfortran/generated/minloc1_16_r10.c |  19 +--
 libgfortran/generated/minloc1_16_r16.c |  19 +--
 libgfortran/generated/minloc1_16_r4.c  |  19 +--
 libgfortran/generated/minloc1_16_r8.c  |  19 +--
 libgfortran/generated/minloc1_4_i1.c   |  19 +--
 libgfortran/generated/minloc1_4_i16.c  |  19 +--
 libgfortran/generated/minloc1_4_i2.c   |  19 +--
 libgfortran/generated/minloc1_4_i4.c   |  19 +--
 libgfortran/generated/minloc1_4_i8.c   |  19 +--
 libgfortran/generated/minloc1_4_r10.c  |  19 +--
 libgfortran/generated/minloc1_4_r16.c  |  19 +--
 libgfortran/generated/minloc1_4_r4.c   |  19 +--
 libgfortran/generated/minloc1_4_r8.c   |  19 +--
 libgfortran/generated/minloc1_8_i1.c   |  19 +--
 libgfortran/generated/minloc1_8_i16.c  |  19 +--
 libgfortran/generated/minloc1_8_i2.c   |  19 +--
 libgfortran/generated/minloc1_8_i4.c   |  19 +--
 libgfortran/generated/minloc1_8_i8.c   |  19 +--
 libgfortran/generated/minloc1_8_r10.c  |  19 +--
 libgfortran/generated/minloc1_8_r16.c  |  19 +--
 libgfortran/generated/minloc1_8_r4.c   |  19 +--
 libgfortran/generated/minloc1_8_r8.c   |  19 +--
 libgfortran/generated/minval_i1.c      |  19 +--
 libgfortran/generated/minval_i16.c     |  19 +--
 libgfortran/generated/minval_i2.c      |  19 +--
 libgfortran/generated/minval_i4.c      |  19 +--
 libgfortran/generated/minval_i8.c      |  19 +--
 libgfortran/generated/minval_r10.c     |  19 +--
 libgfortran/generated/minval_r16.c     |  19 +--
 libgfortran/generated/minval_r4.c      |  19 +--
 libgfortran/generated/minval_r8.c      |  19 +--
 libgfortran/generated/product_c10.c    |  19 +--
 libgfortran/generated/product_c16.c    |  19 +--
 libgfortran/generated/product_c4.c     |  19 +--
 libgfortran/generated/product_c8.c     |  19 +--
 libgfortran/generated/product_i1.c     |  19 +--
 libgfortran/generated/product_i16.c    |  19 +--
 libgfortran/generated/product_i2.c     |  19 +--
 libgfortran/generated/product_i4.c     |  19 +--
 libgfortran/generated/product_i8.c     |  19 +--
 libgfortran/generated/product_r10.c    |  19 +--
 libgfortran/generated/product_r16.c    |  19 +--
 libgfortran/generated/product_r4.c     |  19 +--
 libgfortran/generated/product_r8.c     |  19 +--
 libgfortran/generated/sum_c10.c        |  19 +--
 libgfortran/generated/sum_c16.c        |  19 +--
 libgfortran/generated/sum_c4.c         |  19 +--
 libgfortran/generated/sum_c8.c         |  19 +--
 libgfortran/generated/sum_i1.c         |  19 +--
 libgfortran/generated/sum_i16.c        |  19 +--
 libgfortran/generated/sum_i2.c         |  19 +--
 libgfortran/generated/sum_i4.c         |  19 +--
 libgfortran/generated/sum_i8.c         |  19 +--
 libgfortran/generated/sum_r10.c        |  19 +--
 libgfortran/generated/sum_r16.c        |  19 +--
 libgfortran/generated/sum_r4.c         |  19 +--
 libgfortran/generated/sum_r8.c         |  19 +--
 libgfortran/m4/iforeach.m4             |  21 +--
 libgfortran/m4/ifunction.m4            |  19 +--
 170 files changed, 1849 insertions(+), 1501 deletions(-)

diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 34b730795e15..16ef713c4b5f 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,182 @@
+2008-01-13  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+	PR libfortran/34746
+	* m4/iforeach.m4 (name`'rtype_qual`_'atype_code):  Use %ld
+	in printf format for all bounds checking; cast all
+	integer-like arguments to runtime_error() to long int.
+	(`m'name`'rtype_qual`_'atype_code):  Likewise.
+	(`s'name`'rtype_qual`_'atype_code):  Likewise.
+	* m4/ifunction.m4 (name`'rtype_qual`_'atype_code):  Likewise.
+	(`m'name`'rtype_qual`_'atype_code):  Likewise.
+	(`s'name`'rtype_qual`_'atype_code):  Likewise.
+	* generated/all_l16.c: Regenerated.
+	* generated/all_l4.c: Regenerated.
+	* generated/all_l8.c: Regenerated.
+	* generated/any_l16.c: Regenerated.
+	* generated/any_l4.c: Regenerated.
+	* generated/any_l8.c: Regenerated.
+	* generated/count_16_l16.c: Regenerated.
+	* generated/count_16_l4.c: Regenerated.
+	* generated/count_16_l8.c: Regenerated.
+	* generated/count_4_l16.c: Regenerated.
+	* generated/count_4_l4.c: Regenerated.
+	* generated/count_4_l8.c: Regenerated.
+	* generated/count_8_l16.c: Regenerated.
+	* generated/count_8_l4.c: Regenerated.
+	* generated/count_8_l8.c: Regenerated.
+	* generated/maxloc0_16_i1.c: Regenerated.
+	* generated/maxloc0_16_i16.c: Regenerated.
+	* generated/maxloc0_16_i2.c: Regenerated.
+	* generated/maxloc0_16_i4.c: Regenerated.
+	* generated/maxloc0_16_i8.c: Regenerated.
+	* generated/maxloc0_16_r10.c: Regenerated.
+	* generated/maxloc0_16_r16.c: Regenerated.
+	* generated/maxloc0_16_r4.c: Regenerated.
+	* generated/maxloc0_16_r8.c: Regenerated.
+	* generated/maxloc0_4_i1.c: Regenerated.
+	* generated/maxloc0_4_i16.c: Regenerated.
+	* generated/maxloc0_4_i2.c: Regenerated.
+	* generated/maxloc0_4_i4.c: Regenerated.
+	* generated/maxloc0_4_i8.c: Regenerated.
+	* generated/maxloc0_4_r10.c: Regenerated.
+	* generated/maxloc0_4_r16.c: Regenerated.
+	* generated/maxloc0_4_r4.c: Regenerated.
+	* generated/maxloc0_4_r8.c: Regenerated.
+	* generated/maxloc0_8_i1.c: Regenerated.
+	* generated/maxloc0_8_i16.c: Regenerated.
+	* generated/maxloc0_8_i2.c: Regenerated.
+	* generated/maxloc0_8_i4.c: Regenerated.
+	* generated/maxloc0_8_i8.c: Regenerated.
+	* generated/maxloc0_8_r10.c: Regenerated.
+	* generated/maxloc0_8_r16.c: Regenerated.
+	* generated/maxloc0_8_r4.c: Regenerated.
+	* generated/maxloc0_8_r8.c: Regenerated.
+	* generated/maxloc1_16_i1.c: Regenerated.
+	* generated/maxloc1_16_i16.c: Regenerated.
+	* generated/maxloc1_16_i2.c: Regenerated.
+	* generated/maxloc1_16_i4.c: Regenerated.
+	* generated/maxloc1_16_i8.c: Regenerated.
+	* generated/maxloc1_16_r10.c: Regenerated.
+	* generated/maxloc1_16_r16.c: Regenerated.
+	* generated/maxloc1_16_r4.c: Regenerated.
+	* generated/maxloc1_16_r8.c: Regenerated.
+	* generated/maxloc1_4_i1.c: Regenerated.
+	* generated/maxloc1_4_i16.c: Regenerated.
+	* generated/maxloc1_4_i2.c: Regenerated.
+	* generated/maxloc1_4_i4.c: Regenerated.
+	* generated/maxloc1_4_i8.c: Regenerated.
+	* generated/maxloc1_4_r10.c: Regenerated.
+	* generated/maxloc1_4_r16.c: Regenerated.
+	* generated/maxloc1_4_r4.c: Regenerated.
+	* generated/maxloc1_4_r8.c: Regenerated.
+	* generated/maxloc1_8_i1.c: Regenerated.
+	* generated/maxloc1_8_i16.c: Regenerated.
+	* generated/maxloc1_8_i2.c: Regenerated.
+	* generated/maxloc1_8_i4.c: Regenerated.
+	* generated/maxloc1_8_i8.c: Regenerated.
+	* generated/maxloc1_8_r10.c: Regenerated.
+	* generated/maxloc1_8_r16.c: Regenerated.
+	* generated/maxloc1_8_r4.c: Regenerated.
+	* generated/maxloc1_8_r8.c: Regenerated.
+	* generated/maxval_i1.c: Regenerated.
+	* generated/maxval_i16.c: Regenerated.
+	* generated/maxval_i2.c: Regenerated.
+	* generated/maxval_i4.c: Regenerated.
+	* generated/maxval_i8.c: Regenerated.
+	* generated/maxval_r10.c: Regenerated.
+	* generated/maxval_r16.c: Regenerated.
+	* generated/maxval_r4.c: Regenerated.
+	* generated/maxval_r8.c: Regenerated.
+	* generated/minloc0_16_i1.c: Regenerated.
+	* generated/minloc0_16_i16.c: Regenerated.
+	* generated/minloc0_16_i2.c: Regenerated.
+	* generated/minloc0_16_i4.c: Regenerated.
+	* generated/minloc0_16_i8.c: Regenerated.
+	* generated/minloc0_16_r10.c: Regenerated.
+	* generated/minloc0_16_r16.c: Regenerated.
+	* generated/minloc0_16_r4.c: Regenerated.
+	* generated/minloc0_16_r8.c: Regenerated.
+	* generated/minloc0_4_i1.c: Regenerated.
+	* generated/minloc0_4_i16.c: Regenerated.
+	* generated/minloc0_4_i2.c: Regenerated.
+	* generated/minloc0_4_i4.c: Regenerated.
+	* generated/minloc0_4_i8.c: Regenerated.
+	* generated/minloc0_4_r10.c: Regenerated.
+	* generated/minloc0_4_r16.c: Regenerated.
+	* generated/minloc0_4_r4.c: Regenerated.
+	* generated/minloc0_4_r8.c: Regenerated.
+	* generated/minloc0_8_i1.c: Regenerated.
+	* generated/minloc0_8_i16.c: Regenerated.
+	* generated/minloc0_8_i2.c: Regenerated.
+	* generated/minloc0_8_i4.c: Regenerated.
+	* generated/minloc0_8_i8.c: Regenerated.
+	* generated/minloc0_8_r10.c: Regenerated.
+	* generated/minloc0_8_r16.c: Regenerated.
+	* generated/minloc0_8_r4.c: Regenerated.
+	* generated/minloc0_8_r8.c: Regenerated.
+	* generated/minloc1_16_i1.c: Regenerated.
+	* generated/minloc1_16_i16.c: Regenerated.
+	* generated/minloc1_16_i2.c: Regenerated.
+	* generated/minloc1_16_i4.c: Regenerated.
+	* generated/minloc1_16_i8.c: Regenerated.
+	* generated/minloc1_16_r10.c: Regenerated.
+	* generated/minloc1_16_r16.c: Regenerated.
+	* generated/minloc1_16_r4.c: Regenerated.
+	* generated/minloc1_16_r8.c: Regenerated.
+	* generated/minloc1_4_i1.c: Regenerated.
+	* generated/minloc1_4_i16.c: Regenerated.
+	* generated/minloc1_4_i2.c: Regenerated.
+	* generated/minloc1_4_i4.c: Regenerated.
+	* generated/minloc1_4_i8.c: Regenerated.
+	* generated/minloc1_4_r10.c: Regenerated.
+	* generated/minloc1_4_r16.c: Regenerated.
+	* generated/minloc1_4_r4.c: Regenerated.
+	* generated/minloc1_4_r8.c: Regenerated.
+	* generated/minloc1_8_i1.c: Regenerated.
+	* generated/minloc1_8_i16.c: Regenerated.
+	* generated/minloc1_8_i2.c: Regenerated.
+	* generated/minloc1_8_i4.c: Regenerated.
+	* generated/minloc1_8_i8.c: Regenerated.
+	* generated/minloc1_8_r10.c: Regenerated.
+	* generated/minloc1_8_r16.c: Regenerated.
+	* generated/minloc1_8_r4.c: Regenerated.
+	* generated/minloc1_8_r8.c: Regenerated.
+	* generated/minval_i1.c: Regenerated.
+	* generated/minval_i16.c: Regenerated.
+	* generated/minval_i2.c: Regenerated.
+	* generated/minval_i4.c: Regenerated.
+	* generated/minval_i8.c: Regenerated.
+	* generated/minval_r10.c: Regenerated.
+	* generated/minval_r16.c: Regenerated.
+	* generated/minval_r4.c: Regenerated.
+	* generated/minval_r8.c: Regenerated.
+	* generated/product_c10.c: Regenerated.
+	* generated/product_c16.c: Regenerated.
+	* generated/product_c4.c: Regenerated.
+	* generated/product_c8.c: Regenerated.
+	* generated/product_i1.c: Regenerated.
+	* generated/product_i16.c: Regenerated.
+	* generated/product_i2.c: Regenerated.
+	* generated/product_i4.c: Regenerated.
+	* generated/product_i8.c: Regenerated.
+	* generated/product_r10.c: Regenerated.
+	* generated/product_r16.c: Regenerated.
+	* generated/product_r4.c: Regenerated.
+	* generated/product_r8.c: Regenerated.
+	* generated/sum_c10.c: Regenerated.
+	* generated/sum_c16.c: Regenerated.
+	* generated/sum_c4.c: Regenerated.
+	* generated/sum_c8.c: Regenerated.
+	* generated/sum_i1.c: Regenerated.
+	* generated/sum_i16.c: Regenerated.
+	* generated/sum_i2.c: Regenerated.
+	* generated/sum_i4.c: Regenerated.
+	* generated/sum_i8.c: Regenerated.
+	* generated/sum_r10.c: Regenerated.
+	* generated/sum_r16.c: Regenerated.
+	* generated/sum_r4.c: Regenerated.
+	* generated/sum_r8.c: Regenerated.
+
 2008-01-11  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
 	PR libfortran/34670
diff --git a/libgfortran/generated/all_l16.c b/libgfortran/generated/all_l16.c
index 2cc81ce423a0..9c53707ae762 100644
--- a/libgfortran/generated/all_l16.c
+++ b/libgfortran/generated/all_l16.c
@@ -116,8 +116,9 @@ all_l16 (gfc_array_l16 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " ALL intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " ALL intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ all_l16 (gfc_array_l16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " ALL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " ALL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
diff --git a/libgfortran/generated/all_l4.c b/libgfortran/generated/all_l4.c
index 12f9efb2b915..6eb798619b6b 100644
--- a/libgfortran/generated/all_l4.c
+++ b/libgfortran/generated/all_l4.c
@@ -116,8 +116,9 @@ all_l4 (gfc_array_l4 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " ALL intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " ALL intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ all_l4 (gfc_array_l4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " ALL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " ALL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
diff --git a/libgfortran/generated/all_l8.c b/libgfortran/generated/all_l8.c
index c9fa80935ae8..7b98652bce52 100644
--- a/libgfortran/generated/all_l8.c
+++ b/libgfortran/generated/all_l8.c
@@ -116,8 +116,9 @@ all_l8 (gfc_array_l8 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " ALL intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " ALL intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ all_l8 (gfc_array_l8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " ALL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " ALL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
diff --git a/libgfortran/generated/any_l16.c b/libgfortran/generated/any_l16.c
index 1ba59edbadd1..bffd620f02b9 100644
--- a/libgfortran/generated/any_l16.c
+++ b/libgfortran/generated/any_l16.c
@@ -116,8 +116,9 @@ any_l16 (gfc_array_l16 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " ANY intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " ANY intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ any_l16 (gfc_array_l16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " ANY intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " ANY intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
diff --git a/libgfortran/generated/any_l4.c b/libgfortran/generated/any_l4.c
index 83116ebe9cac..f86445e69e1f 100644
--- a/libgfortran/generated/any_l4.c
+++ b/libgfortran/generated/any_l4.c
@@ -116,8 +116,9 @@ any_l4 (gfc_array_l4 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " ANY intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " ANY intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ any_l4 (gfc_array_l4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " ANY intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " ANY intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
diff --git a/libgfortran/generated/any_l8.c b/libgfortran/generated/any_l8.c
index a85e6e89ca0d..f155abbed362 100644
--- a/libgfortran/generated/any_l8.c
+++ b/libgfortran/generated/any_l8.c
@@ -116,8 +116,9 @@ any_l8 (gfc_array_l8 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " ANY intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " ANY intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ any_l8 (gfc_array_l8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " ANY intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " ANY intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
diff --git a/libgfortran/generated/count_16_l16.c b/libgfortran/generated/count_16_l16.c
index 351eb8a1e656..4f3418bd73a1 100644
--- a/libgfortran/generated/count_16_l16.c
+++ b/libgfortran/generated/count_16_l16.c
@@ -116,8 +116,9 @@ count_16_l16 (gfc_array_i16 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " COUNT intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " COUNT intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ count_16_l16 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " COUNT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " COUNT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
diff --git a/libgfortran/generated/count_16_l4.c b/libgfortran/generated/count_16_l4.c
index 9f849d8b7256..9b853699b9de 100644
--- a/libgfortran/generated/count_16_l4.c
+++ b/libgfortran/generated/count_16_l4.c
@@ -116,8 +116,9 @@ count_16_l4 (gfc_array_i16 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " COUNT intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " COUNT intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ count_16_l4 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " COUNT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " COUNT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
diff --git a/libgfortran/generated/count_16_l8.c b/libgfortran/generated/count_16_l8.c
index 90659da0a177..7a6a31adf0cd 100644
--- a/libgfortran/generated/count_16_l8.c
+++ b/libgfortran/generated/count_16_l8.c
@@ -116,8 +116,9 @@ count_16_l8 (gfc_array_i16 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " COUNT intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " COUNT intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ count_16_l8 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " COUNT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " COUNT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
diff --git a/libgfortran/generated/count_4_l16.c b/libgfortran/generated/count_4_l16.c
index c3b3daad85a5..5dee5468c648 100644
--- a/libgfortran/generated/count_4_l16.c
+++ b/libgfortran/generated/count_4_l16.c
@@ -116,8 +116,9 @@ count_4_l16 (gfc_array_i4 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " COUNT intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " COUNT intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ count_4_l16 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " COUNT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " COUNT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
diff --git a/libgfortran/generated/count_4_l4.c b/libgfortran/generated/count_4_l4.c
index 3bfcf179c75a..04493b2f4b4f 100644
--- a/libgfortran/generated/count_4_l4.c
+++ b/libgfortran/generated/count_4_l4.c
@@ -116,8 +116,9 @@ count_4_l4 (gfc_array_i4 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " COUNT intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " COUNT intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ count_4_l4 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " COUNT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " COUNT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
diff --git a/libgfortran/generated/count_4_l8.c b/libgfortran/generated/count_4_l8.c
index 7debda799bbd..0e2f9bbb5439 100644
--- a/libgfortran/generated/count_4_l8.c
+++ b/libgfortran/generated/count_4_l8.c
@@ -116,8 +116,9 @@ count_4_l8 (gfc_array_i4 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " COUNT intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " COUNT intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ count_4_l8 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " COUNT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " COUNT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
diff --git a/libgfortran/generated/count_8_l16.c b/libgfortran/generated/count_8_l16.c
index 815b79ab65cb..b0d11164fc53 100644
--- a/libgfortran/generated/count_8_l16.c
+++ b/libgfortran/generated/count_8_l16.c
@@ -116,8 +116,9 @@ count_8_l16 (gfc_array_i8 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " COUNT intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " COUNT intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ count_8_l16 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " COUNT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " COUNT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
diff --git a/libgfortran/generated/count_8_l4.c b/libgfortran/generated/count_8_l4.c
index 84401ded1e15..e6a386e8a8d2 100644
--- a/libgfortran/generated/count_8_l4.c
+++ b/libgfortran/generated/count_8_l4.c
@@ -116,8 +116,9 @@ count_8_l4 (gfc_array_i8 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " COUNT intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " COUNT intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ count_8_l4 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " COUNT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " COUNT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
diff --git a/libgfortran/generated/count_8_l8.c b/libgfortran/generated/count_8_l8.c
index fd26280a550c..2a1b2a570de0 100644
--- a/libgfortran/generated/count_8_l8.c
+++ b/libgfortran/generated/count_8_l8.c
@@ -116,8 +116,9 @@ count_8_l8 (gfc_array_i8 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " COUNT intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " COUNT intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ count_8_l8 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " COUNT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " COUNT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
diff --git a/libgfortran/generated/maxloc0_16_i1.c b/libgfortran/generated/maxloc0_16_i1.c
index 3cd6554a3460..7fc44432fa44 100644
--- a/libgfortran/generated/maxloc0_16_i1.c
+++ b/libgfortran/generated/maxloc0_16_i1.c
@@ -77,13 +77,13 @@ maxloc0_16_i1 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mmaxloc0_16_i1 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MAXLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mmaxloc0_16_i1 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ smaxloc0_16_i1 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc0_16_i16.c b/libgfortran/generated/maxloc0_16_i16.c
index 9bfec0430131..29eb3ccecf13 100644
--- a/libgfortran/generated/maxloc0_16_i16.c
+++ b/libgfortran/generated/maxloc0_16_i16.c
@@ -77,13 +77,13 @@ maxloc0_16_i16 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mmaxloc0_16_i16 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MAXLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mmaxloc0_16_i16 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ smaxloc0_16_i16 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc0_16_i2.c b/libgfortran/generated/maxloc0_16_i2.c
index b57e78f92746..30b693c1068f 100644
--- a/libgfortran/generated/maxloc0_16_i2.c
+++ b/libgfortran/generated/maxloc0_16_i2.c
@@ -77,13 +77,13 @@ maxloc0_16_i2 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mmaxloc0_16_i2 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MAXLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mmaxloc0_16_i2 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ smaxloc0_16_i2 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc0_16_i4.c b/libgfortran/generated/maxloc0_16_i4.c
index 2e123b6d2959..03f2794f30ba 100644
--- a/libgfortran/generated/maxloc0_16_i4.c
+++ b/libgfortran/generated/maxloc0_16_i4.c
@@ -77,13 +77,13 @@ maxloc0_16_i4 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mmaxloc0_16_i4 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MAXLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mmaxloc0_16_i4 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ smaxloc0_16_i4 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc0_16_i8.c b/libgfortran/generated/maxloc0_16_i8.c
index cd141a692227..be18af39ce8e 100644
--- a/libgfortran/generated/maxloc0_16_i8.c
+++ b/libgfortran/generated/maxloc0_16_i8.c
@@ -77,13 +77,13 @@ maxloc0_16_i8 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mmaxloc0_16_i8 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MAXLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mmaxloc0_16_i8 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ smaxloc0_16_i8 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc0_16_r10.c b/libgfortran/generated/maxloc0_16_r10.c
index 8426d3af81e4..48ba77e8732a 100644
--- a/libgfortran/generated/maxloc0_16_r10.c
+++ b/libgfortran/generated/maxloc0_16_r10.c
@@ -77,13 +77,13 @@ maxloc0_16_r10 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mmaxloc0_16_r10 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MAXLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mmaxloc0_16_r10 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ smaxloc0_16_r10 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc0_16_r16.c b/libgfortran/generated/maxloc0_16_r16.c
index 3244452c601e..9d2ce0870153 100644
--- a/libgfortran/generated/maxloc0_16_r16.c
+++ b/libgfortran/generated/maxloc0_16_r16.c
@@ -77,13 +77,13 @@ maxloc0_16_r16 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mmaxloc0_16_r16 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MAXLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mmaxloc0_16_r16 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ smaxloc0_16_r16 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc0_16_r4.c b/libgfortran/generated/maxloc0_16_r4.c
index 8057063339c4..e908dadcdd0c 100644
--- a/libgfortran/generated/maxloc0_16_r4.c
+++ b/libgfortran/generated/maxloc0_16_r4.c
@@ -77,13 +77,13 @@ maxloc0_16_r4 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mmaxloc0_16_r4 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MAXLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mmaxloc0_16_r4 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ smaxloc0_16_r4 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc0_16_r8.c b/libgfortran/generated/maxloc0_16_r8.c
index 6c12815a0a11..cb01745a44c1 100644
--- a/libgfortran/generated/maxloc0_16_r8.c
+++ b/libgfortran/generated/maxloc0_16_r8.c
@@ -77,13 +77,13 @@ maxloc0_16_r8 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mmaxloc0_16_r8 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MAXLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mmaxloc0_16_r8 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ smaxloc0_16_r8 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc0_4_i1.c b/libgfortran/generated/maxloc0_4_i1.c
index 42c865a6e29b..21ab578c4025 100644
--- a/libgfortran/generated/maxloc0_4_i1.c
+++ b/libgfortran/generated/maxloc0_4_i1.c
@@ -77,13 +77,13 @@ maxloc0_4_i1 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mmaxloc0_4_i1 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MAXLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mmaxloc0_4_i1 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ smaxloc0_4_i1 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc0_4_i16.c b/libgfortran/generated/maxloc0_4_i16.c
index 938ceba69747..6803420884c7 100644
--- a/libgfortran/generated/maxloc0_4_i16.c
+++ b/libgfortran/generated/maxloc0_4_i16.c
@@ -77,13 +77,13 @@ maxloc0_4_i16 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mmaxloc0_4_i16 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MAXLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mmaxloc0_4_i16 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ smaxloc0_4_i16 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc0_4_i2.c b/libgfortran/generated/maxloc0_4_i2.c
index 809d93821dc5..27cccae97843 100644
--- a/libgfortran/generated/maxloc0_4_i2.c
+++ b/libgfortran/generated/maxloc0_4_i2.c
@@ -77,13 +77,13 @@ maxloc0_4_i2 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mmaxloc0_4_i2 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MAXLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mmaxloc0_4_i2 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ smaxloc0_4_i2 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc0_4_i4.c b/libgfortran/generated/maxloc0_4_i4.c
index 5108cbe13660..650da03a1ed0 100644
--- a/libgfortran/generated/maxloc0_4_i4.c
+++ b/libgfortran/generated/maxloc0_4_i4.c
@@ -77,13 +77,13 @@ maxloc0_4_i4 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mmaxloc0_4_i4 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MAXLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mmaxloc0_4_i4 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ smaxloc0_4_i4 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc0_4_i8.c b/libgfortran/generated/maxloc0_4_i8.c
index 987b424d7e16..48e1d3e52157 100644
--- a/libgfortran/generated/maxloc0_4_i8.c
+++ b/libgfortran/generated/maxloc0_4_i8.c
@@ -77,13 +77,13 @@ maxloc0_4_i8 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mmaxloc0_4_i8 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MAXLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mmaxloc0_4_i8 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ smaxloc0_4_i8 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc0_4_r10.c b/libgfortran/generated/maxloc0_4_r10.c
index b3101bd6ac8d..05e316592386 100644
--- a/libgfortran/generated/maxloc0_4_r10.c
+++ b/libgfortran/generated/maxloc0_4_r10.c
@@ -77,13 +77,13 @@ maxloc0_4_r10 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mmaxloc0_4_r10 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MAXLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mmaxloc0_4_r10 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ smaxloc0_4_r10 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc0_4_r16.c b/libgfortran/generated/maxloc0_4_r16.c
index 9b1e5274a3f9..38cf35272825 100644
--- a/libgfortran/generated/maxloc0_4_r16.c
+++ b/libgfortran/generated/maxloc0_4_r16.c
@@ -77,13 +77,13 @@ maxloc0_4_r16 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mmaxloc0_4_r16 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MAXLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mmaxloc0_4_r16 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ smaxloc0_4_r16 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc0_4_r4.c b/libgfortran/generated/maxloc0_4_r4.c
index bf4692c26f08..5ab9429028eb 100644
--- a/libgfortran/generated/maxloc0_4_r4.c
+++ b/libgfortran/generated/maxloc0_4_r4.c
@@ -77,13 +77,13 @@ maxloc0_4_r4 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mmaxloc0_4_r4 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MAXLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mmaxloc0_4_r4 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ smaxloc0_4_r4 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc0_4_r8.c b/libgfortran/generated/maxloc0_4_r8.c
index 774a6734c2d2..2658e4a5b9ac 100644
--- a/libgfortran/generated/maxloc0_4_r8.c
+++ b/libgfortran/generated/maxloc0_4_r8.c
@@ -77,13 +77,13 @@ maxloc0_4_r8 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mmaxloc0_4_r8 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MAXLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mmaxloc0_4_r8 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ smaxloc0_4_r8 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc0_8_i1.c b/libgfortran/generated/maxloc0_8_i1.c
index 38890b70dcfb..ce71eb1ebbda 100644
--- a/libgfortran/generated/maxloc0_8_i1.c
+++ b/libgfortran/generated/maxloc0_8_i1.c
@@ -77,13 +77,13 @@ maxloc0_8_i1 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mmaxloc0_8_i1 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MAXLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mmaxloc0_8_i1 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ smaxloc0_8_i1 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc0_8_i16.c b/libgfortran/generated/maxloc0_8_i16.c
index be99a8ca0b10..e808a91cf596 100644
--- a/libgfortran/generated/maxloc0_8_i16.c
+++ b/libgfortran/generated/maxloc0_8_i16.c
@@ -77,13 +77,13 @@ maxloc0_8_i16 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mmaxloc0_8_i16 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MAXLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mmaxloc0_8_i16 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ smaxloc0_8_i16 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc0_8_i2.c b/libgfortran/generated/maxloc0_8_i2.c
index 02a5f645e8ec..8bc1961ea3a7 100644
--- a/libgfortran/generated/maxloc0_8_i2.c
+++ b/libgfortran/generated/maxloc0_8_i2.c
@@ -77,13 +77,13 @@ maxloc0_8_i2 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mmaxloc0_8_i2 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MAXLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mmaxloc0_8_i2 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ smaxloc0_8_i2 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc0_8_i4.c b/libgfortran/generated/maxloc0_8_i4.c
index dca0b768861c..8b6d2128a5dd 100644
--- a/libgfortran/generated/maxloc0_8_i4.c
+++ b/libgfortran/generated/maxloc0_8_i4.c
@@ -77,13 +77,13 @@ maxloc0_8_i4 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mmaxloc0_8_i4 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MAXLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mmaxloc0_8_i4 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ smaxloc0_8_i4 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc0_8_i8.c b/libgfortran/generated/maxloc0_8_i8.c
index d11ba2677f2b..121827eabb34 100644
--- a/libgfortran/generated/maxloc0_8_i8.c
+++ b/libgfortran/generated/maxloc0_8_i8.c
@@ -77,13 +77,13 @@ maxloc0_8_i8 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mmaxloc0_8_i8 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MAXLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mmaxloc0_8_i8 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ smaxloc0_8_i8 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc0_8_r10.c b/libgfortran/generated/maxloc0_8_r10.c
index 898f1f576736..8fb4b13eb695 100644
--- a/libgfortran/generated/maxloc0_8_r10.c
+++ b/libgfortran/generated/maxloc0_8_r10.c
@@ -77,13 +77,13 @@ maxloc0_8_r10 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mmaxloc0_8_r10 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MAXLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mmaxloc0_8_r10 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ smaxloc0_8_r10 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc0_8_r16.c b/libgfortran/generated/maxloc0_8_r16.c
index 6dec78a49f96..7a5a4f354af7 100644
--- a/libgfortran/generated/maxloc0_8_r16.c
+++ b/libgfortran/generated/maxloc0_8_r16.c
@@ -77,13 +77,13 @@ maxloc0_8_r16 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mmaxloc0_8_r16 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MAXLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mmaxloc0_8_r16 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ smaxloc0_8_r16 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc0_8_r4.c b/libgfortran/generated/maxloc0_8_r4.c
index 345dbe1a9d16..8e02dcb77180 100644
--- a/libgfortran/generated/maxloc0_8_r4.c
+++ b/libgfortran/generated/maxloc0_8_r4.c
@@ -77,13 +77,13 @@ maxloc0_8_r4 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mmaxloc0_8_r4 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MAXLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mmaxloc0_8_r4 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ smaxloc0_8_r4 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc0_8_r8.c b/libgfortran/generated/maxloc0_8_r8.c
index bf7020e1a101..c539df0596d8 100644
--- a/libgfortran/generated/maxloc0_8_r8.c
+++ b/libgfortran/generated/maxloc0_8_r8.c
@@ -77,13 +77,13 @@ maxloc0_8_r8 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mmaxloc0_8_r8 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MAXLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MAXLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MAXLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mmaxloc0_8_r8 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ smaxloc0_8_r8 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc1_16_i1.c b/libgfortran/generated/maxloc1_16_i1.c
index 477eb704a868..47e67239322c 100644
--- a/libgfortran/generated/maxloc1_16_i1.c
+++ b/libgfortran/generated/maxloc1_16_i1.c
@@ -117,8 +117,9 @@ maxloc1_16_i1 (gfc_array_i16 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MAXLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MAXLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ maxloc1_16_i1 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mmaxloc1_16_i1 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mmaxloc1_16_i1 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ smaxloc1_16_i1 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc1_16_i16.c b/libgfortran/generated/maxloc1_16_i16.c
index e4a2c1b361b9..2c8a06cb6757 100644
--- a/libgfortran/generated/maxloc1_16_i16.c
+++ b/libgfortran/generated/maxloc1_16_i16.c
@@ -117,8 +117,9 @@ maxloc1_16_i16 (gfc_array_i16 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MAXLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MAXLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ maxloc1_16_i16 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mmaxloc1_16_i16 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mmaxloc1_16_i16 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ smaxloc1_16_i16 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc1_16_i2.c b/libgfortran/generated/maxloc1_16_i2.c
index f5d7b587aed2..d7b1ca57eede 100644
--- a/libgfortran/generated/maxloc1_16_i2.c
+++ b/libgfortran/generated/maxloc1_16_i2.c
@@ -117,8 +117,9 @@ maxloc1_16_i2 (gfc_array_i16 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MAXLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MAXLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ maxloc1_16_i2 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mmaxloc1_16_i2 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mmaxloc1_16_i2 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ smaxloc1_16_i2 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc1_16_i4.c b/libgfortran/generated/maxloc1_16_i4.c
index 1fbda541ae3e..394c0160261d 100644
--- a/libgfortran/generated/maxloc1_16_i4.c
+++ b/libgfortran/generated/maxloc1_16_i4.c
@@ -117,8 +117,9 @@ maxloc1_16_i4 (gfc_array_i16 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MAXLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MAXLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ maxloc1_16_i4 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mmaxloc1_16_i4 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mmaxloc1_16_i4 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ smaxloc1_16_i4 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc1_16_i8.c b/libgfortran/generated/maxloc1_16_i8.c
index 59be84cd62c0..5cff65dece47 100644
--- a/libgfortran/generated/maxloc1_16_i8.c
+++ b/libgfortran/generated/maxloc1_16_i8.c
@@ -117,8 +117,9 @@ maxloc1_16_i8 (gfc_array_i16 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MAXLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MAXLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ maxloc1_16_i8 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mmaxloc1_16_i8 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mmaxloc1_16_i8 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ smaxloc1_16_i8 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc1_16_r10.c b/libgfortran/generated/maxloc1_16_r10.c
index 3a8c8b7a376e..32af8cd88544 100644
--- a/libgfortran/generated/maxloc1_16_r10.c
+++ b/libgfortran/generated/maxloc1_16_r10.c
@@ -117,8 +117,9 @@ maxloc1_16_r10 (gfc_array_i16 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MAXLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MAXLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ maxloc1_16_r10 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mmaxloc1_16_r10 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mmaxloc1_16_r10 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ smaxloc1_16_r10 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc1_16_r16.c b/libgfortran/generated/maxloc1_16_r16.c
index 60b97249adae..d695ad8ec5d6 100644
--- a/libgfortran/generated/maxloc1_16_r16.c
+++ b/libgfortran/generated/maxloc1_16_r16.c
@@ -117,8 +117,9 @@ maxloc1_16_r16 (gfc_array_i16 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MAXLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MAXLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ maxloc1_16_r16 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mmaxloc1_16_r16 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mmaxloc1_16_r16 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ smaxloc1_16_r16 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc1_16_r4.c b/libgfortran/generated/maxloc1_16_r4.c
index a36a9d1133c6..05dfbe380a7e 100644
--- a/libgfortran/generated/maxloc1_16_r4.c
+++ b/libgfortran/generated/maxloc1_16_r4.c
@@ -117,8 +117,9 @@ maxloc1_16_r4 (gfc_array_i16 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MAXLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MAXLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ maxloc1_16_r4 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mmaxloc1_16_r4 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mmaxloc1_16_r4 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ smaxloc1_16_r4 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc1_16_r8.c b/libgfortran/generated/maxloc1_16_r8.c
index 9c659c0d3a6a..a060e0620a8a 100644
--- a/libgfortran/generated/maxloc1_16_r8.c
+++ b/libgfortran/generated/maxloc1_16_r8.c
@@ -117,8 +117,9 @@ maxloc1_16_r8 (gfc_array_i16 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MAXLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MAXLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ maxloc1_16_r8 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mmaxloc1_16_r8 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mmaxloc1_16_r8 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ smaxloc1_16_r8 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc1_4_i1.c b/libgfortran/generated/maxloc1_4_i1.c
index 1d9132888cd1..2244456c1544 100644
--- a/libgfortran/generated/maxloc1_4_i1.c
+++ b/libgfortran/generated/maxloc1_4_i1.c
@@ -117,8 +117,9 @@ maxloc1_4_i1 (gfc_array_i4 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MAXLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MAXLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ maxloc1_4_i1 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mmaxloc1_4_i1 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mmaxloc1_4_i1 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ smaxloc1_4_i1 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc1_4_i16.c b/libgfortran/generated/maxloc1_4_i16.c
index 92a08bef0bd2..d0f260c962d9 100644
--- a/libgfortran/generated/maxloc1_4_i16.c
+++ b/libgfortran/generated/maxloc1_4_i16.c
@@ -117,8 +117,9 @@ maxloc1_4_i16 (gfc_array_i4 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MAXLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MAXLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ maxloc1_4_i16 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mmaxloc1_4_i16 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mmaxloc1_4_i16 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ smaxloc1_4_i16 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc1_4_i2.c b/libgfortran/generated/maxloc1_4_i2.c
index b03d90a95920..5415ebabacfa 100644
--- a/libgfortran/generated/maxloc1_4_i2.c
+++ b/libgfortran/generated/maxloc1_4_i2.c
@@ -117,8 +117,9 @@ maxloc1_4_i2 (gfc_array_i4 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MAXLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MAXLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ maxloc1_4_i2 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mmaxloc1_4_i2 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mmaxloc1_4_i2 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ smaxloc1_4_i2 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc1_4_i4.c b/libgfortran/generated/maxloc1_4_i4.c
index dc90ec29d8da..291b919945d0 100644
--- a/libgfortran/generated/maxloc1_4_i4.c
+++ b/libgfortran/generated/maxloc1_4_i4.c
@@ -117,8 +117,9 @@ maxloc1_4_i4 (gfc_array_i4 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MAXLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MAXLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ maxloc1_4_i4 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mmaxloc1_4_i4 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mmaxloc1_4_i4 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ smaxloc1_4_i4 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc1_4_i8.c b/libgfortran/generated/maxloc1_4_i8.c
index 78da94438cd6..97a904dc6875 100644
--- a/libgfortran/generated/maxloc1_4_i8.c
+++ b/libgfortran/generated/maxloc1_4_i8.c
@@ -117,8 +117,9 @@ maxloc1_4_i8 (gfc_array_i4 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MAXLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MAXLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ maxloc1_4_i8 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mmaxloc1_4_i8 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mmaxloc1_4_i8 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ smaxloc1_4_i8 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc1_4_r10.c b/libgfortran/generated/maxloc1_4_r10.c
index 1c83f62f7289..07ccb242ae4b 100644
--- a/libgfortran/generated/maxloc1_4_r10.c
+++ b/libgfortran/generated/maxloc1_4_r10.c
@@ -117,8 +117,9 @@ maxloc1_4_r10 (gfc_array_i4 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MAXLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MAXLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ maxloc1_4_r10 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mmaxloc1_4_r10 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mmaxloc1_4_r10 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ smaxloc1_4_r10 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc1_4_r16.c b/libgfortran/generated/maxloc1_4_r16.c
index a31d0ac5afaa..5ecfffd7b044 100644
--- a/libgfortran/generated/maxloc1_4_r16.c
+++ b/libgfortran/generated/maxloc1_4_r16.c
@@ -117,8 +117,9 @@ maxloc1_4_r16 (gfc_array_i4 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MAXLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MAXLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ maxloc1_4_r16 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mmaxloc1_4_r16 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mmaxloc1_4_r16 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ smaxloc1_4_r16 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc1_4_r4.c b/libgfortran/generated/maxloc1_4_r4.c
index 49d9cd5463bb..f859cc761996 100644
--- a/libgfortran/generated/maxloc1_4_r4.c
+++ b/libgfortran/generated/maxloc1_4_r4.c
@@ -117,8 +117,9 @@ maxloc1_4_r4 (gfc_array_i4 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MAXLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MAXLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ maxloc1_4_r4 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mmaxloc1_4_r4 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mmaxloc1_4_r4 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ smaxloc1_4_r4 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc1_4_r8.c b/libgfortran/generated/maxloc1_4_r8.c
index 822680a49411..5d673420fd9e 100644
--- a/libgfortran/generated/maxloc1_4_r8.c
+++ b/libgfortran/generated/maxloc1_4_r8.c
@@ -117,8 +117,9 @@ maxloc1_4_r8 (gfc_array_i4 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MAXLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MAXLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ maxloc1_4_r8 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mmaxloc1_4_r8 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mmaxloc1_4_r8 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ smaxloc1_4_r8 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc1_8_i1.c b/libgfortran/generated/maxloc1_8_i1.c
index 5c607532dbc1..f9ea707ab95d 100644
--- a/libgfortran/generated/maxloc1_8_i1.c
+++ b/libgfortran/generated/maxloc1_8_i1.c
@@ -117,8 +117,9 @@ maxloc1_8_i1 (gfc_array_i8 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MAXLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MAXLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ maxloc1_8_i1 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mmaxloc1_8_i1 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mmaxloc1_8_i1 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ smaxloc1_8_i1 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc1_8_i16.c b/libgfortran/generated/maxloc1_8_i16.c
index feefc084883e..478a8bc87b0c 100644
--- a/libgfortran/generated/maxloc1_8_i16.c
+++ b/libgfortran/generated/maxloc1_8_i16.c
@@ -117,8 +117,9 @@ maxloc1_8_i16 (gfc_array_i8 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MAXLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MAXLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ maxloc1_8_i16 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mmaxloc1_8_i16 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mmaxloc1_8_i16 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ smaxloc1_8_i16 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc1_8_i2.c b/libgfortran/generated/maxloc1_8_i2.c
index 8e4868d73080..972767f6558a 100644
--- a/libgfortran/generated/maxloc1_8_i2.c
+++ b/libgfortran/generated/maxloc1_8_i2.c
@@ -117,8 +117,9 @@ maxloc1_8_i2 (gfc_array_i8 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MAXLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MAXLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ maxloc1_8_i2 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mmaxloc1_8_i2 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mmaxloc1_8_i2 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ smaxloc1_8_i2 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc1_8_i4.c b/libgfortran/generated/maxloc1_8_i4.c
index cb9d14d8d1d7..e3b566d57ec4 100644
--- a/libgfortran/generated/maxloc1_8_i4.c
+++ b/libgfortran/generated/maxloc1_8_i4.c
@@ -117,8 +117,9 @@ maxloc1_8_i4 (gfc_array_i8 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MAXLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MAXLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ maxloc1_8_i4 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mmaxloc1_8_i4 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mmaxloc1_8_i4 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ smaxloc1_8_i4 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc1_8_i8.c b/libgfortran/generated/maxloc1_8_i8.c
index 8b8f2a969145..e30e104dfc6a 100644
--- a/libgfortran/generated/maxloc1_8_i8.c
+++ b/libgfortran/generated/maxloc1_8_i8.c
@@ -117,8 +117,9 @@ maxloc1_8_i8 (gfc_array_i8 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MAXLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MAXLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ maxloc1_8_i8 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mmaxloc1_8_i8 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mmaxloc1_8_i8 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ smaxloc1_8_i8 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc1_8_r10.c b/libgfortran/generated/maxloc1_8_r10.c
index 6aa6ec1941c4..01e30f660e44 100644
--- a/libgfortran/generated/maxloc1_8_r10.c
+++ b/libgfortran/generated/maxloc1_8_r10.c
@@ -117,8 +117,9 @@ maxloc1_8_r10 (gfc_array_i8 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MAXLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MAXLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ maxloc1_8_r10 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mmaxloc1_8_r10 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mmaxloc1_8_r10 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ smaxloc1_8_r10 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc1_8_r16.c b/libgfortran/generated/maxloc1_8_r16.c
index 59db207cfc00..fbe72d1874fa 100644
--- a/libgfortran/generated/maxloc1_8_r16.c
+++ b/libgfortran/generated/maxloc1_8_r16.c
@@ -117,8 +117,9 @@ maxloc1_8_r16 (gfc_array_i8 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MAXLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MAXLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ maxloc1_8_r16 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mmaxloc1_8_r16 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mmaxloc1_8_r16 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ smaxloc1_8_r16 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc1_8_r4.c b/libgfortran/generated/maxloc1_8_r4.c
index 3640a5dea963..3985d684fe4f 100644
--- a/libgfortran/generated/maxloc1_8_r4.c
+++ b/libgfortran/generated/maxloc1_8_r4.c
@@ -117,8 +117,9 @@ maxloc1_8_r4 (gfc_array_i8 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MAXLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MAXLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ maxloc1_8_r4 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mmaxloc1_8_r4 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mmaxloc1_8_r4 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ smaxloc1_8_r4 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxloc1_8_r8.c b/libgfortran/generated/maxloc1_8_r8.c
index 93c7c78aec74..6e7745b31ba9 100644
--- a/libgfortran/generated/maxloc1_8_r8.c
+++ b/libgfortran/generated/maxloc1_8_r8.c
@@ -117,8 +117,9 @@ maxloc1_8_r8 (gfc_array_i8 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MAXLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MAXLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ maxloc1_8_r8 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mmaxloc1_8_r8 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mmaxloc1_8_r8 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ smaxloc1_8_r8 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxval_i1.c b/libgfortran/generated/maxval_i1.c
index 5158e2a60cc5..901f4e7f2a7f 100644
--- a/libgfortran/generated/maxval_i1.c
+++ b/libgfortran/generated/maxval_i1.c
@@ -116,8 +116,9 @@ maxval_i1 (gfc_array_i1 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MAXVAL intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MAXVAL intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ maxval_i1 (gfc_array_i1 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -317,8 +318,8 @@ mmaxval_i1 (gfc_array_i1 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -329,8 +330,8 @@ mmaxval_i1 (gfc_array_i1 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -449,7 +450,7 @@ smaxval_i1 (gfc_array_i1 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXVAL intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxval_i16.c b/libgfortran/generated/maxval_i16.c
index a10c8fa57c9e..c082e856922d 100644
--- a/libgfortran/generated/maxval_i16.c
+++ b/libgfortran/generated/maxval_i16.c
@@ -116,8 +116,9 @@ maxval_i16 (gfc_array_i16 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MAXVAL intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MAXVAL intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ maxval_i16 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -317,8 +318,8 @@ mmaxval_i16 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -329,8 +330,8 @@ mmaxval_i16 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -449,7 +450,7 @@ smaxval_i16 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXVAL intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxval_i2.c b/libgfortran/generated/maxval_i2.c
index 3819e0e01017..87865e1b49b1 100644
--- a/libgfortran/generated/maxval_i2.c
+++ b/libgfortran/generated/maxval_i2.c
@@ -116,8 +116,9 @@ maxval_i2 (gfc_array_i2 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MAXVAL intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MAXVAL intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ maxval_i2 (gfc_array_i2 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -317,8 +318,8 @@ mmaxval_i2 (gfc_array_i2 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -329,8 +330,8 @@ mmaxval_i2 (gfc_array_i2 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -449,7 +450,7 @@ smaxval_i2 (gfc_array_i2 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXVAL intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxval_i4.c b/libgfortran/generated/maxval_i4.c
index 1076336a02fb..3fa4a10b1bf5 100644
--- a/libgfortran/generated/maxval_i4.c
+++ b/libgfortran/generated/maxval_i4.c
@@ -116,8 +116,9 @@ maxval_i4 (gfc_array_i4 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MAXVAL intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MAXVAL intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ maxval_i4 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -317,8 +318,8 @@ mmaxval_i4 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -329,8 +330,8 @@ mmaxval_i4 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -449,7 +450,7 @@ smaxval_i4 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXVAL intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxval_i8.c b/libgfortran/generated/maxval_i8.c
index f527983097c5..8b2106d209f6 100644
--- a/libgfortran/generated/maxval_i8.c
+++ b/libgfortran/generated/maxval_i8.c
@@ -116,8 +116,9 @@ maxval_i8 (gfc_array_i8 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MAXVAL intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MAXVAL intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ maxval_i8 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -317,8 +318,8 @@ mmaxval_i8 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -329,8 +330,8 @@ mmaxval_i8 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -449,7 +450,7 @@ smaxval_i8 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXVAL intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxval_r10.c b/libgfortran/generated/maxval_r10.c
index fd775c0e4d5a..a076190e8af7 100644
--- a/libgfortran/generated/maxval_r10.c
+++ b/libgfortran/generated/maxval_r10.c
@@ -116,8 +116,9 @@ maxval_r10 (gfc_array_r10 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MAXVAL intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MAXVAL intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ maxval_r10 (gfc_array_r10 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -317,8 +318,8 @@ mmaxval_r10 (gfc_array_r10 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -329,8 +330,8 @@ mmaxval_r10 (gfc_array_r10 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -449,7 +450,7 @@ smaxval_r10 (gfc_array_r10 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXVAL intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxval_r16.c b/libgfortran/generated/maxval_r16.c
index 671ce1499f93..1e36379048bc 100644
--- a/libgfortran/generated/maxval_r16.c
+++ b/libgfortran/generated/maxval_r16.c
@@ -116,8 +116,9 @@ maxval_r16 (gfc_array_r16 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MAXVAL intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MAXVAL intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ maxval_r16 (gfc_array_r16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -317,8 +318,8 @@ mmaxval_r16 (gfc_array_r16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -329,8 +330,8 @@ mmaxval_r16 (gfc_array_r16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -449,7 +450,7 @@ smaxval_r16 (gfc_array_r16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXVAL intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxval_r4.c b/libgfortran/generated/maxval_r4.c
index 674142274e92..222a4e3beeec 100644
--- a/libgfortran/generated/maxval_r4.c
+++ b/libgfortran/generated/maxval_r4.c
@@ -116,8 +116,9 @@ maxval_r4 (gfc_array_r4 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MAXVAL intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MAXVAL intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ maxval_r4 (gfc_array_r4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -317,8 +318,8 @@ mmaxval_r4 (gfc_array_r4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -329,8 +330,8 @@ mmaxval_r4 (gfc_array_r4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -449,7 +450,7 @@ smaxval_r4 (gfc_array_r4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXVAL intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/maxval_r8.c b/libgfortran/generated/maxval_r8.c
index 136ef20794c0..163ec5a1b030 100644
--- a/libgfortran/generated/maxval_r8.c
+++ b/libgfortran/generated/maxval_r8.c
@@ -116,8 +116,9 @@ maxval_r8 (gfc_array_r8 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MAXVAL intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MAXVAL intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ maxval_r8 (gfc_array_r8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -317,8 +318,8 @@ mmaxval_r8 (gfc_array_r8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MAXVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -329,8 +330,8 @@ mmaxval_r8 (gfc_array_r8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MAXVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MAXVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -449,7 +450,7 @@ smaxval_r8 (gfc_array_r8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MAXVAL intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc0_16_i1.c b/libgfortran/generated/minloc0_16_i1.c
index 9529997a3747..d0d6903bf411 100644
--- a/libgfortran/generated/minloc0_16_i1.c
+++ b/libgfortran/generated/minloc0_16_i1.c
@@ -77,13 +77,13 @@ minloc0_16_i1 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mminloc0_16_i1 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MINLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mminloc0_16_i1 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ sminloc0_16_i1 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc0_16_i16.c b/libgfortran/generated/minloc0_16_i16.c
index 667bfd8a3491..59c1d0abbf89 100644
--- a/libgfortran/generated/minloc0_16_i16.c
+++ b/libgfortran/generated/minloc0_16_i16.c
@@ -77,13 +77,13 @@ minloc0_16_i16 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mminloc0_16_i16 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MINLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mminloc0_16_i16 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ sminloc0_16_i16 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc0_16_i2.c b/libgfortran/generated/minloc0_16_i2.c
index a5c499410bd8..0df6bd189c5b 100644
--- a/libgfortran/generated/minloc0_16_i2.c
+++ b/libgfortran/generated/minloc0_16_i2.c
@@ -77,13 +77,13 @@ minloc0_16_i2 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mminloc0_16_i2 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MINLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mminloc0_16_i2 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ sminloc0_16_i2 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc0_16_i4.c b/libgfortran/generated/minloc0_16_i4.c
index 7c9292cddb36..48bb60be7375 100644
--- a/libgfortran/generated/minloc0_16_i4.c
+++ b/libgfortran/generated/minloc0_16_i4.c
@@ -77,13 +77,13 @@ minloc0_16_i4 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mminloc0_16_i4 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MINLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mminloc0_16_i4 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ sminloc0_16_i4 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc0_16_i8.c b/libgfortran/generated/minloc0_16_i8.c
index 022e49c97078..b92f7e430313 100644
--- a/libgfortran/generated/minloc0_16_i8.c
+++ b/libgfortran/generated/minloc0_16_i8.c
@@ -77,13 +77,13 @@ minloc0_16_i8 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mminloc0_16_i8 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MINLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mminloc0_16_i8 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ sminloc0_16_i8 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc0_16_r10.c b/libgfortran/generated/minloc0_16_r10.c
index a99c5307afcb..6480a8dd681e 100644
--- a/libgfortran/generated/minloc0_16_r10.c
+++ b/libgfortran/generated/minloc0_16_r10.c
@@ -77,13 +77,13 @@ minloc0_16_r10 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mminloc0_16_r10 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MINLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mminloc0_16_r10 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ sminloc0_16_r10 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc0_16_r16.c b/libgfortran/generated/minloc0_16_r16.c
index 2b2dcaacb239..325c8f68d509 100644
--- a/libgfortran/generated/minloc0_16_r16.c
+++ b/libgfortran/generated/minloc0_16_r16.c
@@ -77,13 +77,13 @@ minloc0_16_r16 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mminloc0_16_r16 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MINLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mminloc0_16_r16 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ sminloc0_16_r16 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc0_16_r4.c b/libgfortran/generated/minloc0_16_r4.c
index f265ae475612..2376d4034b67 100644
--- a/libgfortran/generated/minloc0_16_r4.c
+++ b/libgfortran/generated/minloc0_16_r4.c
@@ -77,13 +77,13 @@ minloc0_16_r4 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mminloc0_16_r4 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MINLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mminloc0_16_r4 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ sminloc0_16_r4 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc0_16_r8.c b/libgfortran/generated/minloc0_16_r8.c
index 59429f22ee92..e72abab2c5bd 100644
--- a/libgfortran/generated/minloc0_16_r8.c
+++ b/libgfortran/generated/minloc0_16_r8.c
@@ -77,13 +77,13 @@ minloc0_16_r8 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mminloc0_16_r8 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MINLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mminloc0_16_r8 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ sminloc0_16_r8 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc0_4_i1.c b/libgfortran/generated/minloc0_4_i1.c
index 24463ead318d..ce045a28e731 100644
--- a/libgfortran/generated/minloc0_4_i1.c
+++ b/libgfortran/generated/minloc0_4_i1.c
@@ -77,13 +77,13 @@ minloc0_4_i1 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mminloc0_4_i1 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MINLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mminloc0_4_i1 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ sminloc0_4_i1 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc0_4_i16.c b/libgfortran/generated/minloc0_4_i16.c
index ddcbc60eab96..9ae856e686c3 100644
--- a/libgfortran/generated/minloc0_4_i16.c
+++ b/libgfortran/generated/minloc0_4_i16.c
@@ -77,13 +77,13 @@ minloc0_4_i16 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mminloc0_4_i16 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MINLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mminloc0_4_i16 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ sminloc0_4_i16 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc0_4_i2.c b/libgfortran/generated/minloc0_4_i2.c
index 60b2c3fcb579..c33e99cfedba 100644
--- a/libgfortran/generated/minloc0_4_i2.c
+++ b/libgfortran/generated/minloc0_4_i2.c
@@ -77,13 +77,13 @@ minloc0_4_i2 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mminloc0_4_i2 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MINLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mminloc0_4_i2 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ sminloc0_4_i2 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc0_4_i4.c b/libgfortran/generated/minloc0_4_i4.c
index 6431f38ba591..9d7eda6c8394 100644
--- a/libgfortran/generated/minloc0_4_i4.c
+++ b/libgfortran/generated/minloc0_4_i4.c
@@ -77,13 +77,13 @@ minloc0_4_i4 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mminloc0_4_i4 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MINLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mminloc0_4_i4 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ sminloc0_4_i4 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc0_4_i8.c b/libgfortran/generated/minloc0_4_i8.c
index 6ffeac577fc6..046e040daf0b 100644
--- a/libgfortran/generated/minloc0_4_i8.c
+++ b/libgfortran/generated/minloc0_4_i8.c
@@ -77,13 +77,13 @@ minloc0_4_i8 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mminloc0_4_i8 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MINLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mminloc0_4_i8 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ sminloc0_4_i8 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc0_4_r10.c b/libgfortran/generated/minloc0_4_r10.c
index e4f10024c50e..8f7b92478686 100644
--- a/libgfortran/generated/minloc0_4_r10.c
+++ b/libgfortran/generated/minloc0_4_r10.c
@@ -77,13 +77,13 @@ minloc0_4_r10 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mminloc0_4_r10 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MINLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mminloc0_4_r10 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ sminloc0_4_r10 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc0_4_r16.c b/libgfortran/generated/minloc0_4_r16.c
index 0f9fb9804679..1539192ca158 100644
--- a/libgfortran/generated/minloc0_4_r16.c
+++ b/libgfortran/generated/minloc0_4_r16.c
@@ -77,13 +77,13 @@ minloc0_4_r16 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mminloc0_4_r16 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MINLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mminloc0_4_r16 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ sminloc0_4_r16 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc0_4_r4.c b/libgfortran/generated/minloc0_4_r4.c
index 14c63b35e133..86ffdb8c6efc 100644
--- a/libgfortran/generated/minloc0_4_r4.c
+++ b/libgfortran/generated/minloc0_4_r4.c
@@ -77,13 +77,13 @@ minloc0_4_r4 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mminloc0_4_r4 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MINLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mminloc0_4_r4 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ sminloc0_4_r4 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc0_4_r8.c b/libgfortran/generated/minloc0_4_r8.c
index 168d0ad26211..e78cdd898f52 100644
--- a/libgfortran/generated/minloc0_4_r8.c
+++ b/libgfortran/generated/minloc0_4_r8.c
@@ -77,13 +77,13 @@ minloc0_4_r8 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mminloc0_4_r8 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MINLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mminloc0_4_r8 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ sminloc0_4_r8 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc0_8_i1.c b/libgfortran/generated/minloc0_8_i1.c
index 6dcafbae05de..5872d85560db 100644
--- a/libgfortran/generated/minloc0_8_i1.c
+++ b/libgfortran/generated/minloc0_8_i1.c
@@ -77,13 +77,13 @@ minloc0_8_i1 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mminloc0_8_i1 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MINLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mminloc0_8_i1 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ sminloc0_8_i1 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc0_8_i16.c b/libgfortran/generated/minloc0_8_i16.c
index f2afae1e643f..b56409a050c7 100644
--- a/libgfortran/generated/minloc0_8_i16.c
+++ b/libgfortran/generated/minloc0_8_i16.c
@@ -77,13 +77,13 @@ minloc0_8_i16 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mminloc0_8_i16 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MINLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mminloc0_8_i16 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ sminloc0_8_i16 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc0_8_i2.c b/libgfortran/generated/minloc0_8_i2.c
index d0dd13744276..63cd947c42d5 100644
--- a/libgfortran/generated/minloc0_8_i2.c
+++ b/libgfortran/generated/minloc0_8_i2.c
@@ -77,13 +77,13 @@ minloc0_8_i2 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mminloc0_8_i2 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MINLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mminloc0_8_i2 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ sminloc0_8_i2 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc0_8_i4.c b/libgfortran/generated/minloc0_8_i4.c
index a4c921acfe3f..5092f89f7062 100644
--- a/libgfortran/generated/minloc0_8_i4.c
+++ b/libgfortran/generated/minloc0_8_i4.c
@@ -77,13 +77,13 @@ minloc0_8_i4 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mminloc0_8_i4 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MINLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mminloc0_8_i4 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ sminloc0_8_i4 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc0_8_i8.c b/libgfortran/generated/minloc0_8_i8.c
index 26aa9476cf44..e1b99ef9f940 100644
--- a/libgfortran/generated/minloc0_8_i8.c
+++ b/libgfortran/generated/minloc0_8_i8.c
@@ -77,13 +77,13 @@ minloc0_8_i8 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mminloc0_8_i8 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MINLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mminloc0_8_i8 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ sminloc0_8_i8 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc0_8_r10.c b/libgfortran/generated/minloc0_8_r10.c
index b1705ebc5fd8..600b3aa6af05 100644
--- a/libgfortran/generated/minloc0_8_r10.c
+++ b/libgfortran/generated/minloc0_8_r10.c
@@ -77,13 +77,13 @@ minloc0_8_r10 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mminloc0_8_r10 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MINLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mminloc0_8_r10 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ sminloc0_8_r10 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc0_8_r16.c b/libgfortran/generated/minloc0_8_r16.c
index 84b95baa6a59..fa4b5cd1d560 100644
--- a/libgfortran/generated/minloc0_8_r16.c
+++ b/libgfortran/generated/minloc0_8_r16.c
@@ -77,13 +77,13 @@ minloc0_8_r16 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mminloc0_8_r16 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MINLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mminloc0_8_r16 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ sminloc0_8_r16 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc0_8_r4.c b/libgfortran/generated/minloc0_8_r4.c
index d7b8d547ecec..1347f15c8a88 100644
--- a/libgfortran/generated/minloc0_8_r4.c
+++ b/libgfortran/generated/minloc0_8_r4.c
@@ -77,13 +77,13 @@ minloc0_8_r4 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mminloc0_8_r4 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MINLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mminloc0_8_r4 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ sminloc0_8_r4 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc0_8_r8.c b/libgfortran/generated/minloc0_8_r8.c
index 6ac0bfe1b00e..6a7b2f0d6b01 100644
--- a/libgfortran/generated/minloc0_8_r8.c
+++ b/libgfortran/generated/minloc0_8_r8.c
@@ -77,13 +77,13 @@ minloc0_8_r8 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -203,18 +203,19 @@ mminloc0_8_r8 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " MINLOC intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " MINLOC intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in MINLOC intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -222,8 +223,8 @@ mminloc0_8_r8 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -360,7 +361,7 @@ sminloc0_8_r8 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc1_16_i1.c b/libgfortran/generated/minloc1_16_i1.c
index c1baf547b4b8..f4abfa8f0d1e 100644
--- a/libgfortran/generated/minloc1_16_i1.c
+++ b/libgfortran/generated/minloc1_16_i1.c
@@ -117,8 +117,9 @@ minloc1_16_i1 (gfc_array_i16 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MINLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MINLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ minloc1_16_i1 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mminloc1_16_i1 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mminloc1_16_i1 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ sminloc1_16_i1 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc1_16_i16.c b/libgfortran/generated/minloc1_16_i16.c
index db992cb4a7cf..40b86eadc6c9 100644
--- a/libgfortran/generated/minloc1_16_i16.c
+++ b/libgfortran/generated/minloc1_16_i16.c
@@ -117,8 +117,9 @@ minloc1_16_i16 (gfc_array_i16 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MINLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MINLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ minloc1_16_i16 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mminloc1_16_i16 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mminloc1_16_i16 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ sminloc1_16_i16 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc1_16_i2.c b/libgfortran/generated/minloc1_16_i2.c
index 523a4affff4f..f7057b2c849b 100644
--- a/libgfortran/generated/minloc1_16_i2.c
+++ b/libgfortran/generated/minloc1_16_i2.c
@@ -117,8 +117,9 @@ minloc1_16_i2 (gfc_array_i16 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MINLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MINLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ minloc1_16_i2 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mminloc1_16_i2 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mminloc1_16_i2 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ sminloc1_16_i2 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc1_16_i4.c b/libgfortran/generated/minloc1_16_i4.c
index e8d5fc397c6e..3cf6f0de83fa 100644
--- a/libgfortran/generated/minloc1_16_i4.c
+++ b/libgfortran/generated/minloc1_16_i4.c
@@ -117,8 +117,9 @@ minloc1_16_i4 (gfc_array_i16 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MINLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MINLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ minloc1_16_i4 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mminloc1_16_i4 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mminloc1_16_i4 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ sminloc1_16_i4 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc1_16_i8.c b/libgfortran/generated/minloc1_16_i8.c
index 8c3e4e482426..a0838687ba88 100644
--- a/libgfortran/generated/minloc1_16_i8.c
+++ b/libgfortran/generated/minloc1_16_i8.c
@@ -117,8 +117,9 @@ minloc1_16_i8 (gfc_array_i16 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MINLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MINLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ minloc1_16_i8 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mminloc1_16_i8 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mminloc1_16_i8 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ sminloc1_16_i8 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc1_16_r10.c b/libgfortran/generated/minloc1_16_r10.c
index 7aa89a947ccc..20b1c5789a7d 100644
--- a/libgfortran/generated/minloc1_16_r10.c
+++ b/libgfortran/generated/minloc1_16_r10.c
@@ -117,8 +117,9 @@ minloc1_16_r10 (gfc_array_i16 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MINLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MINLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ minloc1_16_r10 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mminloc1_16_r10 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mminloc1_16_r10 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ sminloc1_16_r10 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc1_16_r16.c b/libgfortran/generated/minloc1_16_r16.c
index 5b814451d600..40fcbaea3f95 100644
--- a/libgfortran/generated/minloc1_16_r16.c
+++ b/libgfortran/generated/minloc1_16_r16.c
@@ -117,8 +117,9 @@ minloc1_16_r16 (gfc_array_i16 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MINLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MINLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ minloc1_16_r16 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mminloc1_16_r16 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mminloc1_16_r16 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ sminloc1_16_r16 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc1_16_r4.c b/libgfortran/generated/minloc1_16_r4.c
index b3c61552ffed..76e7efaf0eba 100644
--- a/libgfortran/generated/minloc1_16_r4.c
+++ b/libgfortran/generated/minloc1_16_r4.c
@@ -117,8 +117,9 @@ minloc1_16_r4 (gfc_array_i16 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MINLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MINLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ minloc1_16_r4 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mminloc1_16_r4 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mminloc1_16_r4 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ sminloc1_16_r4 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc1_16_r8.c b/libgfortran/generated/minloc1_16_r8.c
index 0a4b1b507776..97ca8661dfbb 100644
--- a/libgfortran/generated/minloc1_16_r8.c
+++ b/libgfortran/generated/minloc1_16_r8.c
@@ -117,8 +117,9 @@ minloc1_16_r8 (gfc_array_i16 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MINLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MINLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ minloc1_16_r8 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mminloc1_16_r8 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mminloc1_16_r8 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ sminloc1_16_r8 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc1_4_i1.c b/libgfortran/generated/minloc1_4_i1.c
index 9cebebe10a03..330c0d9b91a1 100644
--- a/libgfortran/generated/minloc1_4_i1.c
+++ b/libgfortran/generated/minloc1_4_i1.c
@@ -117,8 +117,9 @@ minloc1_4_i1 (gfc_array_i4 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MINLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MINLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ minloc1_4_i1 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mminloc1_4_i1 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mminloc1_4_i1 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ sminloc1_4_i1 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc1_4_i16.c b/libgfortran/generated/minloc1_4_i16.c
index a984a153d380..a142adb9630a 100644
--- a/libgfortran/generated/minloc1_4_i16.c
+++ b/libgfortran/generated/minloc1_4_i16.c
@@ -117,8 +117,9 @@ minloc1_4_i16 (gfc_array_i4 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MINLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MINLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ minloc1_4_i16 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mminloc1_4_i16 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mminloc1_4_i16 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ sminloc1_4_i16 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc1_4_i2.c b/libgfortran/generated/minloc1_4_i2.c
index 685f9793b73f..d7a92804094c 100644
--- a/libgfortran/generated/minloc1_4_i2.c
+++ b/libgfortran/generated/minloc1_4_i2.c
@@ -117,8 +117,9 @@ minloc1_4_i2 (gfc_array_i4 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MINLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MINLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ minloc1_4_i2 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mminloc1_4_i2 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mminloc1_4_i2 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ sminloc1_4_i2 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc1_4_i4.c b/libgfortran/generated/minloc1_4_i4.c
index f44a631d352b..c6b12e84e261 100644
--- a/libgfortran/generated/minloc1_4_i4.c
+++ b/libgfortran/generated/minloc1_4_i4.c
@@ -117,8 +117,9 @@ minloc1_4_i4 (gfc_array_i4 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MINLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MINLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ minloc1_4_i4 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mminloc1_4_i4 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mminloc1_4_i4 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ sminloc1_4_i4 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc1_4_i8.c b/libgfortran/generated/minloc1_4_i8.c
index f6858c028205..bac4eb5fc821 100644
--- a/libgfortran/generated/minloc1_4_i8.c
+++ b/libgfortran/generated/minloc1_4_i8.c
@@ -117,8 +117,9 @@ minloc1_4_i8 (gfc_array_i4 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MINLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MINLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ minloc1_4_i8 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mminloc1_4_i8 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mminloc1_4_i8 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ sminloc1_4_i8 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc1_4_r10.c b/libgfortran/generated/minloc1_4_r10.c
index 8e359fe15193..0579519ab0de 100644
--- a/libgfortran/generated/minloc1_4_r10.c
+++ b/libgfortran/generated/minloc1_4_r10.c
@@ -117,8 +117,9 @@ minloc1_4_r10 (gfc_array_i4 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MINLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MINLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ minloc1_4_r10 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mminloc1_4_r10 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mminloc1_4_r10 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ sminloc1_4_r10 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc1_4_r16.c b/libgfortran/generated/minloc1_4_r16.c
index 11cb9c8f9627..d74d26dc6057 100644
--- a/libgfortran/generated/minloc1_4_r16.c
+++ b/libgfortran/generated/minloc1_4_r16.c
@@ -117,8 +117,9 @@ minloc1_4_r16 (gfc_array_i4 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MINLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MINLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ minloc1_4_r16 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mminloc1_4_r16 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mminloc1_4_r16 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ sminloc1_4_r16 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc1_4_r4.c b/libgfortran/generated/minloc1_4_r4.c
index 31aa1f7a6210..050ed5c3c793 100644
--- a/libgfortran/generated/minloc1_4_r4.c
+++ b/libgfortran/generated/minloc1_4_r4.c
@@ -117,8 +117,9 @@ minloc1_4_r4 (gfc_array_i4 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MINLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MINLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ minloc1_4_r4 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mminloc1_4_r4 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mminloc1_4_r4 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ sminloc1_4_r4 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc1_4_r8.c b/libgfortran/generated/minloc1_4_r8.c
index a7a56b67f897..483cd19f2629 100644
--- a/libgfortran/generated/minloc1_4_r8.c
+++ b/libgfortran/generated/minloc1_4_r8.c
@@ -117,8 +117,9 @@ minloc1_4_r8 (gfc_array_i4 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MINLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MINLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ minloc1_4_r8 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mminloc1_4_r8 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mminloc1_4_r8 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ sminloc1_4_r8 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc1_8_i1.c b/libgfortran/generated/minloc1_8_i1.c
index 1fae32b3fb66..1fc81d106e20 100644
--- a/libgfortran/generated/minloc1_8_i1.c
+++ b/libgfortran/generated/minloc1_8_i1.c
@@ -117,8 +117,9 @@ minloc1_8_i1 (gfc_array_i8 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MINLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MINLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ minloc1_8_i1 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mminloc1_8_i1 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mminloc1_8_i1 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ sminloc1_8_i1 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc1_8_i16.c b/libgfortran/generated/minloc1_8_i16.c
index 0d31c944b851..ecbabc7a9818 100644
--- a/libgfortran/generated/minloc1_8_i16.c
+++ b/libgfortran/generated/minloc1_8_i16.c
@@ -117,8 +117,9 @@ minloc1_8_i16 (gfc_array_i8 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MINLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MINLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ minloc1_8_i16 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mminloc1_8_i16 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mminloc1_8_i16 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ sminloc1_8_i16 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc1_8_i2.c b/libgfortran/generated/minloc1_8_i2.c
index 88655757ddc0..2c03443258e2 100644
--- a/libgfortran/generated/minloc1_8_i2.c
+++ b/libgfortran/generated/minloc1_8_i2.c
@@ -117,8 +117,9 @@ minloc1_8_i2 (gfc_array_i8 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MINLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MINLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ minloc1_8_i2 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mminloc1_8_i2 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mminloc1_8_i2 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ sminloc1_8_i2 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc1_8_i4.c b/libgfortran/generated/minloc1_8_i4.c
index 31ee2385b36d..945423748c5c 100644
--- a/libgfortran/generated/minloc1_8_i4.c
+++ b/libgfortran/generated/minloc1_8_i4.c
@@ -117,8 +117,9 @@ minloc1_8_i4 (gfc_array_i8 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MINLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MINLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ minloc1_8_i4 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mminloc1_8_i4 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mminloc1_8_i4 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ sminloc1_8_i4 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc1_8_i8.c b/libgfortran/generated/minloc1_8_i8.c
index 13577aba741e..df801458e09a 100644
--- a/libgfortran/generated/minloc1_8_i8.c
+++ b/libgfortran/generated/minloc1_8_i8.c
@@ -117,8 +117,9 @@ minloc1_8_i8 (gfc_array_i8 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MINLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MINLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ minloc1_8_i8 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mminloc1_8_i8 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mminloc1_8_i8 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ sminloc1_8_i8 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc1_8_r10.c b/libgfortran/generated/minloc1_8_r10.c
index 726aa1c89370..364bf5c6f04f 100644
--- a/libgfortran/generated/minloc1_8_r10.c
+++ b/libgfortran/generated/minloc1_8_r10.c
@@ -117,8 +117,9 @@ minloc1_8_r10 (gfc_array_i8 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MINLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MINLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ minloc1_8_r10 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mminloc1_8_r10 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mminloc1_8_r10 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ sminloc1_8_r10 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc1_8_r16.c b/libgfortran/generated/minloc1_8_r16.c
index aaf9797856db..b8ad0950ec5e 100644
--- a/libgfortran/generated/minloc1_8_r16.c
+++ b/libgfortran/generated/minloc1_8_r16.c
@@ -117,8 +117,9 @@ minloc1_8_r16 (gfc_array_i8 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MINLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MINLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ minloc1_8_r16 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mminloc1_8_r16 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mminloc1_8_r16 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ sminloc1_8_r16 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc1_8_r4.c b/libgfortran/generated/minloc1_8_r4.c
index 6b0bcec629cf..e9df66c669f7 100644
--- a/libgfortran/generated/minloc1_8_r4.c
+++ b/libgfortran/generated/minloc1_8_r4.c
@@ -117,8 +117,9 @@ minloc1_8_r4 (gfc_array_i8 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MINLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MINLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ minloc1_8_r4 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mminloc1_8_r4 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mminloc1_8_r4 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ sminloc1_8_r4 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minloc1_8_r8.c b/libgfortran/generated/minloc1_8_r8.c
index 8a8d266393df..7d2cfff7fed0 100644
--- a/libgfortran/generated/minloc1_8_r8.c
+++ b/libgfortran/generated/minloc1_8_r8.c
@@ -117,8 +117,9 @@ minloc1_8_r8 (gfc_array_i8 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MINLOC intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MINLOC intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -130,8 +131,8 @@ minloc1_8_r8 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -323,8 +324,8 @@ mminloc1_8_r8 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -335,8 +336,8 @@ mminloc1_8_r8 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINLOC intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINLOC intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -460,7 +461,7 @@ sminloc1_8_r8 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINLOC intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minval_i1.c b/libgfortran/generated/minval_i1.c
index ef31ba0c8d8f..1789ec9fcfad 100644
--- a/libgfortran/generated/minval_i1.c
+++ b/libgfortran/generated/minval_i1.c
@@ -116,8 +116,9 @@ minval_i1 (gfc_array_i1 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MINVAL intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MINVAL intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ minval_i1 (gfc_array_i1 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -317,8 +318,8 @@ mminval_i1 (gfc_array_i1 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -329,8 +330,8 @@ mminval_i1 (gfc_array_i1 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -449,7 +450,7 @@ sminval_i1 (gfc_array_i1 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINVAL intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minval_i16.c b/libgfortran/generated/minval_i16.c
index 8d7bf50c4aed..2916256e3ebd 100644
--- a/libgfortran/generated/minval_i16.c
+++ b/libgfortran/generated/minval_i16.c
@@ -116,8 +116,9 @@ minval_i16 (gfc_array_i16 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MINVAL intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MINVAL intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ minval_i16 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -317,8 +318,8 @@ mminval_i16 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -329,8 +330,8 @@ mminval_i16 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -449,7 +450,7 @@ sminval_i16 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINVAL intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minval_i2.c b/libgfortran/generated/minval_i2.c
index c3d63f6482b7..73bf18b61673 100644
--- a/libgfortran/generated/minval_i2.c
+++ b/libgfortran/generated/minval_i2.c
@@ -116,8 +116,9 @@ minval_i2 (gfc_array_i2 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MINVAL intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MINVAL intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ minval_i2 (gfc_array_i2 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -317,8 +318,8 @@ mminval_i2 (gfc_array_i2 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -329,8 +330,8 @@ mminval_i2 (gfc_array_i2 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -449,7 +450,7 @@ sminval_i2 (gfc_array_i2 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINVAL intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minval_i4.c b/libgfortran/generated/minval_i4.c
index 48ea446db9cb..8d6e52a2ac0c 100644
--- a/libgfortran/generated/minval_i4.c
+++ b/libgfortran/generated/minval_i4.c
@@ -116,8 +116,9 @@ minval_i4 (gfc_array_i4 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MINVAL intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MINVAL intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ minval_i4 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -317,8 +318,8 @@ mminval_i4 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -329,8 +330,8 @@ mminval_i4 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -449,7 +450,7 @@ sminval_i4 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINVAL intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minval_i8.c b/libgfortran/generated/minval_i8.c
index cd2100a05ace..22cf462d0605 100644
--- a/libgfortran/generated/minval_i8.c
+++ b/libgfortran/generated/minval_i8.c
@@ -116,8 +116,9 @@ minval_i8 (gfc_array_i8 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MINVAL intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MINVAL intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ minval_i8 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -317,8 +318,8 @@ mminval_i8 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -329,8 +330,8 @@ mminval_i8 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -449,7 +450,7 @@ sminval_i8 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINVAL intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minval_r10.c b/libgfortran/generated/minval_r10.c
index 10d0302d4ee1..f4d467c0d992 100644
--- a/libgfortran/generated/minval_r10.c
+++ b/libgfortran/generated/minval_r10.c
@@ -116,8 +116,9 @@ minval_r10 (gfc_array_r10 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MINVAL intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MINVAL intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ minval_r10 (gfc_array_r10 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -317,8 +318,8 @@ mminval_r10 (gfc_array_r10 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -329,8 +330,8 @@ mminval_r10 (gfc_array_r10 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -449,7 +450,7 @@ sminval_r10 (gfc_array_r10 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINVAL intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minval_r16.c b/libgfortran/generated/minval_r16.c
index da6e7963a3a1..7ba19c99c1bc 100644
--- a/libgfortran/generated/minval_r16.c
+++ b/libgfortran/generated/minval_r16.c
@@ -116,8 +116,9 @@ minval_r16 (gfc_array_r16 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MINVAL intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MINVAL intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ minval_r16 (gfc_array_r16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -317,8 +318,8 @@ mminval_r16 (gfc_array_r16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -329,8 +330,8 @@ mminval_r16 (gfc_array_r16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -449,7 +450,7 @@ sminval_r16 (gfc_array_r16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINVAL intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minval_r4.c b/libgfortran/generated/minval_r4.c
index 745889a81311..3b29f2f5d3b9 100644
--- a/libgfortran/generated/minval_r4.c
+++ b/libgfortran/generated/minval_r4.c
@@ -116,8 +116,9 @@ minval_r4 (gfc_array_r4 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MINVAL intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MINVAL intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ minval_r4 (gfc_array_r4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -317,8 +318,8 @@ mminval_r4 (gfc_array_r4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -329,8 +330,8 @@ mminval_r4 (gfc_array_r4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -449,7 +450,7 @@ sminval_r4 (gfc_array_r4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINVAL intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/minval_r8.c b/libgfortran/generated/minval_r8.c
index 1b0fec0174a5..adca8b28c7d3 100644
--- a/libgfortran/generated/minval_r8.c
+++ b/libgfortran/generated/minval_r8.c
@@ -116,8 +116,9 @@ minval_r8 (gfc_array_r8 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " MINVAL intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " MINVAL intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ minval_r8 (gfc_array_r8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -317,8 +318,8 @@ mminval_r8 (gfc_array_r8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " MINVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -329,8 +330,8 @@ mminval_r8 (gfc_array_r8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " MINVAL intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " MINVAL intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -449,7 +450,7 @@ sminval_r8 (gfc_array_r8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in MINVAL intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/product_c10.c b/libgfortran/generated/product_c10.c
index 701835f9a43e..def678ab953e 100644
--- a/libgfortran/generated/product_c10.c
+++ b/libgfortran/generated/product_c10.c
@@ -116,8 +116,9 @@ product_c10 (gfc_array_c10 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " PRODUCT intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " PRODUCT intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ product_c10 (gfc_array_c10 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -316,8 +317,8 @@ mproduct_c10 (gfc_array_c10 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -328,8 +329,8 @@ mproduct_c10 (gfc_array_c10 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -448,7 +449,7 @@ sproduct_c10 (gfc_array_c10 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in PRODUCT intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/product_c16.c b/libgfortran/generated/product_c16.c
index 1d58a7687568..d8750aef5b00 100644
--- a/libgfortran/generated/product_c16.c
+++ b/libgfortran/generated/product_c16.c
@@ -116,8 +116,9 @@ product_c16 (gfc_array_c16 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " PRODUCT intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " PRODUCT intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ product_c16 (gfc_array_c16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -316,8 +317,8 @@ mproduct_c16 (gfc_array_c16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -328,8 +329,8 @@ mproduct_c16 (gfc_array_c16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -448,7 +449,7 @@ sproduct_c16 (gfc_array_c16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in PRODUCT intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/product_c4.c b/libgfortran/generated/product_c4.c
index 3754fcb5cae7..7cac33fc8c63 100644
--- a/libgfortran/generated/product_c4.c
+++ b/libgfortran/generated/product_c4.c
@@ -116,8 +116,9 @@ product_c4 (gfc_array_c4 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " PRODUCT intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " PRODUCT intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ product_c4 (gfc_array_c4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -316,8 +317,8 @@ mproduct_c4 (gfc_array_c4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -328,8 +329,8 @@ mproduct_c4 (gfc_array_c4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -448,7 +449,7 @@ sproduct_c4 (gfc_array_c4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in PRODUCT intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/product_c8.c b/libgfortran/generated/product_c8.c
index 6312451b794d..e4f0f6bfd303 100644
--- a/libgfortran/generated/product_c8.c
+++ b/libgfortran/generated/product_c8.c
@@ -116,8 +116,9 @@ product_c8 (gfc_array_c8 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " PRODUCT intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " PRODUCT intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ product_c8 (gfc_array_c8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -316,8 +317,8 @@ mproduct_c8 (gfc_array_c8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -328,8 +329,8 @@ mproduct_c8 (gfc_array_c8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -448,7 +449,7 @@ sproduct_c8 (gfc_array_c8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in PRODUCT intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/product_i1.c b/libgfortran/generated/product_i1.c
index 7003129a4f7b..5a428cad202f 100644
--- a/libgfortran/generated/product_i1.c
+++ b/libgfortran/generated/product_i1.c
@@ -116,8 +116,9 @@ product_i1 (gfc_array_i1 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " PRODUCT intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " PRODUCT intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ product_i1 (gfc_array_i1 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -316,8 +317,8 @@ mproduct_i1 (gfc_array_i1 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -328,8 +329,8 @@ mproduct_i1 (gfc_array_i1 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -448,7 +449,7 @@ sproduct_i1 (gfc_array_i1 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in PRODUCT intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/product_i16.c b/libgfortran/generated/product_i16.c
index 3c448082195b..a1593a4f66a4 100644
--- a/libgfortran/generated/product_i16.c
+++ b/libgfortran/generated/product_i16.c
@@ -116,8 +116,9 @@ product_i16 (gfc_array_i16 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " PRODUCT intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " PRODUCT intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ product_i16 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -316,8 +317,8 @@ mproduct_i16 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -328,8 +329,8 @@ mproduct_i16 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -448,7 +449,7 @@ sproduct_i16 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in PRODUCT intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/product_i2.c b/libgfortran/generated/product_i2.c
index ca57d29dc207..16793f895795 100644
--- a/libgfortran/generated/product_i2.c
+++ b/libgfortran/generated/product_i2.c
@@ -116,8 +116,9 @@ product_i2 (gfc_array_i2 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " PRODUCT intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " PRODUCT intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ product_i2 (gfc_array_i2 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -316,8 +317,8 @@ mproduct_i2 (gfc_array_i2 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -328,8 +329,8 @@ mproduct_i2 (gfc_array_i2 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -448,7 +449,7 @@ sproduct_i2 (gfc_array_i2 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in PRODUCT intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/product_i4.c b/libgfortran/generated/product_i4.c
index d31eb6e15989..cbace913d6af 100644
--- a/libgfortran/generated/product_i4.c
+++ b/libgfortran/generated/product_i4.c
@@ -116,8 +116,9 @@ product_i4 (gfc_array_i4 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " PRODUCT intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " PRODUCT intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ product_i4 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -316,8 +317,8 @@ mproduct_i4 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -328,8 +329,8 @@ mproduct_i4 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -448,7 +449,7 @@ sproduct_i4 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in PRODUCT intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/product_i8.c b/libgfortran/generated/product_i8.c
index 8867aaea2fdf..f1fc56718a81 100644
--- a/libgfortran/generated/product_i8.c
+++ b/libgfortran/generated/product_i8.c
@@ -116,8 +116,9 @@ product_i8 (gfc_array_i8 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " PRODUCT intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " PRODUCT intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ product_i8 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -316,8 +317,8 @@ mproduct_i8 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -328,8 +329,8 @@ mproduct_i8 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -448,7 +449,7 @@ sproduct_i8 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in PRODUCT intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/product_r10.c b/libgfortran/generated/product_r10.c
index 235b8a664ddd..4b7c5803096a 100644
--- a/libgfortran/generated/product_r10.c
+++ b/libgfortran/generated/product_r10.c
@@ -116,8 +116,9 @@ product_r10 (gfc_array_r10 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " PRODUCT intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " PRODUCT intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ product_r10 (gfc_array_r10 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -316,8 +317,8 @@ mproduct_r10 (gfc_array_r10 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -328,8 +329,8 @@ mproduct_r10 (gfc_array_r10 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -448,7 +449,7 @@ sproduct_r10 (gfc_array_r10 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in PRODUCT intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/product_r16.c b/libgfortran/generated/product_r16.c
index 2f837e303f1c..b18155bd73ca 100644
--- a/libgfortran/generated/product_r16.c
+++ b/libgfortran/generated/product_r16.c
@@ -116,8 +116,9 @@ product_r16 (gfc_array_r16 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " PRODUCT intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " PRODUCT intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ product_r16 (gfc_array_r16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -316,8 +317,8 @@ mproduct_r16 (gfc_array_r16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -328,8 +329,8 @@ mproduct_r16 (gfc_array_r16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -448,7 +449,7 @@ sproduct_r16 (gfc_array_r16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in PRODUCT intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/product_r4.c b/libgfortran/generated/product_r4.c
index 4e6c3d178ef6..754cac2bfb18 100644
--- a/libgfortran/generated/product_r4.c
+++ b/libgfortran/generated/product_r4.c
@@ -116,8 +116,9 @@ product_r4 (gfc_array_r4 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " PRODUCT intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " PRODUCT intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ product_r4 (gfc_array_r4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -316,8 +317,8 @@ mproduct_r4 (gfc_array_r4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -328,8 +329,8 @@ mproduct_r4 (gfc_array_r4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -448,7 +449,7 @@ sproduct_r4 (gfc_array_r4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in PRODUCT intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/product_r8.c b/libgfortran/generated/product_r8.c
index 849d404869d2..5f68856a8b02 100644
--- a/libgfortran/generated/product_r8.c
+++ b/libgfortran/generated/product_r8.c
@@ -116,8 +116,9 @@ product_r8 (gfc_array_r8 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " PRODUCT intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " PRODUCT intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ product_r8 (gfc_array_r8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -316,8 +317,8 @@ mproduct_r8 (gfc_array_r8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -328,8 +329,8 @@ mproduct_r8 (gfc_array_r8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " PRODUCT intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " PRODUCT intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -448,7 +449,7 @@ sproduct_r8 (gfc_array_r8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in PRODUCT intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/sum_c10.c b/libgfortran/generated/sum_c10.c
index f3da38498081..e495a0ba4977 100644
--- a/libgfortran/generated/sum_c10.c
+++ b/libgfortran/generated/sum_c10.c
@@ -116,8 +116,9 @@ sum_c10 (gfc_array_c10 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " SUM intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " SUM intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ sum_c10 (gfc_array_c10 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -316,8 +317,8 @@ msum_c10 (gfc_array_c10 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -328,8 +329,8 @@ msum_c10 (gfc_array_c10 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -448,7 +449,7 @@ ssum_c10 (gfc_array_c10 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in SUM intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/sum_c16.c b/libgfortran/generated/sum_c16.c
index df79daf313a5..c73083a930c2 100644
--- a/libgfortran/generated/sum_c16.c
+++ b/libgfortran/generated/sum_c16.c
@@ -116,8 +116,9 @@ sum_c16 (gfc_array_c16 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " SUM intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " SUM intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ sum_c16 (gfc_array_c16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -316,8 +317,8 @@ msum_c16 (gfc_array_c16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -328,8 +329,8 @@ msum_c16 (gfc_array_c16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -448,7 +449,7 @@ ssum_c16 (gfc_array_c16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in SUM intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/sum_c4.c b/libgfortran/generated/sum_c4.c
index 9ef9e8399f7c..6f32327ad0b2 100644
--- a/libgfortran/generated/sum_c4.c
+++ b/libgfortran/generated/sum_c4.c
@@ -116,8 +116,9 @@ sum_c4 (gfc_array_c4 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " SUM intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " SUM intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ sum_c4 (gfc_array_c4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -316,8 +317,8 @@ msum_c4 (gfc_array_c4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -328,8 +329,8 @@ msum_c4 (gfc_array_c4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -448,7 +449,7 @@ ssum_c4 (gfc_array_c4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in SUM intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/sum_c8.c b/libgfortran/generated/sum_c8.c
index a7f7392e7475..80db1101cfe4 100644
--- a/libgfortran/generated/sum_c8.c
+++ b/libgfortran/generated/sum_c8.c
@@ -116,8 +116,9 @@ sum_c8 (gfc_array_c8 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " SUM intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " SUM intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ sum_c8 (gfc_array_c8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -316,8 +317,8 @@ msum_c8 (gfc_array_c8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -328,8 +329,8 @@ msum_c8 (gfc_array_c8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -448,7 +449,7 @@ ssum_c8 (gfc_array_c8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in SUM intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/sum_i1.c b/libgfortran/generated/sum_i1.c
index 8740fb79b5ee..c652712d4e7f 100644
--- a/libgfortran/generated/sum_i1.c
+++ b/libgfortran/generated/sum_i1.c
@@ -116,8 +116,9 @@ sum_i1 (gfc_array_i1 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " SUM intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " SUM intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ sum_i1 (gfc_array_i1 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -316,8 +317,8 @@ msum_i1 (gfc_array_i1 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -328,8 +329,8 @@ msum_i1 (gfc_array_i1 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -448,7 +449,7 @@ ssum_i1 (gfc_array_i1 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in SUM intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/sum_i16.c b/libgfortran/generated/sum_i16.c
index 6500d178fa4d..43a29a2956f8 100644
--- a/libgfortran/generated/sum_i16.c
+++ b/libgfortran/generated/sum_i16.c
@@ -116,8 +116,9 @@ sum_i16 (gfc_array_i16 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " SUM intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " SUM intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ sum_i16 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -316,8 +317,8 @@ msum_i16 (gfc_array_i16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -328,8 +329,8 @@ msum_i16 (gfc_array_i16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -448,7 +449,7 @@ ssum_i16 (gfc_array_i16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in SUM intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/sum_i2.c b/libgfortran/generated/sum_i2.c
index 10202c35ac8a..6c6fcc1116a3 100644
--- a/libgfortran/generated/sum_i2.c
+++ b/libgfortran/generated/sum_i2.c
@@ -116,8 +116,9 @@ sum_i2 (gfc_array_i2 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " SUM intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " SUM intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ sum_i2 (gfc_array_i2 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -316,8 +317,8 @@ msum_i2 (gfc_array_i2 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -328,8 +329,8 @@ msum_i2 (gfc_array_i2 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -448,7 +449,7 @@ ssum_i2 (gfc_array_i2 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in SUM intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/sum_i4.c b/libgfortran/generated/sum_i4.c
index 4d0e8a4a963e..e28d2c96fdf3 100644
--- a/libgfortran/generated/sum_i4.c
+++ b/libgfortran/generated/sum_i4.c
@@ -116,8 +116,9 @@ sum_i4 (gfc_array_i4 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " SUM intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " SUM intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ sum_i4 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -316,8 +317,8 @@ msum_i4 (gfc_array_i4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -328,8 +329,8 @@ msum_i4 (gfc_array_i4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -448,7 +449,7 @@ ssum_i4 (gfc_array_i4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in SUM intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/sum_i8.c b/libgfortran/generated/sum_i8.c
index 8b280a81e0d1..6e824f1ca56f 100644
--- a/libgfortran/generated/sum_i8.c
+++ b/libgfortran/generated/sum_i8.c
@@ -116,8 +116,9 @@ sum_i8 (gfc_array_i8 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " SUM intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " SUM intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ sum_i8 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -316,8 +317,8 @@ msum_i8 (gfc_array_i8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -328,8 +329,8 @@ msum_i8 (gfc_array_i8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -448,7 +449,7 @@ ssum_i8 (gfc_array_i8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in SUM intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/sum_r10.c b/libgfortran/generated/sum_r10.c
index 0fd8775f93ca..1ebd1ed54254 100644
--- a/libgfortran/generated/sum_r10.c
+++ b/libgfortran/generated/sum_r10.c
@@ -116,8 +116,9 @@ sum_r10 (gfc_array_r10 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " SUM intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " SUM intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ sum_r10 (gfc_array_r10 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -316,8 +317,8 @@ msum_r10 (gfc_array_r10 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -328,8 +329,8 @@ msum_r10 (gfc_array_r10 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -448,7 +449,7 @@ ssum_r10 (gfc_array_r10 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in SUM intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/sum_r16.c b/libgfortran/generated/sum_r16.c
index 8903b64d8bcf..0038983a6b4a 100644
--- a/libgfortran/generated/sum_r16.c
+++ b/libgfortran/generated/sum_r16.c
@@ -116,8 +116,9 @@ sum_r16 (gfc_array_r16 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " SUM intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " SUM intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ sum_r16 (gfc_array_r16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -316,8 +317,8 @@ msum_r16 (gfc_array_r16 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -328,8 +329,8 @@ msum_r16 (gfc_array_r16 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -448,7 +449,7 @@ ssum_r16 (gfc_array_r16 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in SUM intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/sum_r4.c b/libgfortran/generated/sum_r4.c
index 1d3f2d09008e..1f058dcbda05 100644
--- a/libgfortran/generated/sum_r4.c
+++ b/libgfortran/generated/sum_r4.c
@@ -116,8 +116,9 @@ sum_r4 (gfc_array_r4 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " SUM intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " SUM intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ sum_r4 (gfc_array_r4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -316,8 +317,8 @@ msum_r4 (gfc_array_r4 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -328,8 +329,8 @@ msum_r4 (gfc_array_r4 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -448,7 +449,7 @@ ssum_r4 (gfc_array_r4 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in SUM intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/generated/sum_r8.c b/libgfortran/generated/sum_r8.c
index d049876d5f2f..82a03bc81f70 100644
--- a/libgfortran/generated/sum_r8.c
+++ b/libgfortran/generated/sum_r8.c
@@ -116,8 +116,9 @@ sum_r8 (gfc_array_r8 * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " SUM intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " SUM intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -129,8 +130,8 @@ sum_r8 (gfc_array_r8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -316,8 +317,8 @@ msum_r8 (gfc_array_r8 * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -328,8 +329,8 @@ msum_r8 (gfc_array_r8 * const restrict retarray,
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " SUM intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " SUM intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -448,7 +449,7 @@ ssum_r8 (gfc_array_r8 * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in SUM intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/m4/iforeach.m4 b/libgfortran/m4/iforeach.m4
index a49d33b9311e..071900b03b8e 100644
--- a/libgfortran/m4/iforeach.m4
+++ b/libgfortran/m4/iforeach.m4
@@ -44,13 +44,13 @@ name`'rtype_qual`_'atype_code (rtype * const restrict retarray,
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in u_name intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " u_name intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " u_name intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	}
     }
 
@@ -162,18 +162,19 @@ void
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in u_name intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	  if (ret_extent != rank)
 	    runtime_error ("Incorrect extent in return value of"
-			   " u_name intrnisic: is %ld, should be %d",
-			   (long int) ret_extent, rank);
+			   " u_name intrnisic: is %ld, should be %ld",
+			   (long int) ret_extent, (long int) rank);
 	
 	  mask_rank = GFC_DESCRIPTOR_RANK (mask);
 	  if (rank != mask_rank)
 	    runtime_error ("rank of MASK argument in u_name intrnisic"
-	                   "should be %d, is %d", rank, mask_rank);
+	                   "should be %ld, is %ld", (long int) rank,
+			   (long int) mask_rank);
 
 	  for (n=0; n<rank; n++)
 	    {
@@ -181,8 +182,8 @@ void
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " u_name intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " u_name intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -318,7 +319,7 @@ void
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in u_name intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
diff --git a/libgfortran/m4/ifunction.m4 b/libgfortran/m4/ifunction.m4
index 965fff8acc53..9769e4d2ddb6 100644
--- a/libgfortran/m4/ifunction.m4
+++ b/libgfortran/m4/ifunction.m4
@@ -99,8 +99,9 @@ name`'rtype_qual`_'atype_code (rtype * const restrict retarray,
     {
       if (rank != GFC_DESCRIPTOR_RANK (retarray))
 	runtime_error ("rank of return array incorrect in"
-		       " u_name intrinsic: is %d, should be %d",
-		       GFC_DESCRIPTOR_RANK (retarray), rank);
+		       " u_name intrinsic: is %ld, should be %ld",
+		       (long int) (GFC_DESCRIPTOR_RANK (retarray)),
+		       (long int) rank);
 
       if (compile_options.bounds_check)
 	{
@@ -112,8 +113,8 @@ name`'rtype_qual`_'atype_code (rtype * const restrict retarray,
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " u_name intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " u_name intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
 	}
@@ -299,8 +300,8 @@ void
 		- retarray->dim[n].lbound;
 	      if (extent[n] != ret_extent)
 		runtime_error ("Incorrect extent in return value of"
-			       " u_name intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " u_name intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) ret_extent, (long int) extent[n]);
 	    }
           for (n=0; n<= rank; n++)
@@ -311,8 +312,8 @@ void
 	      mask_extent = mask->dim[n].ubound + 1 - mask->dim[n].lbound;
 	      if (array_extent != mask_extent)
 		runtime_error ("Incorrect extent in MASK argument of"
-			       " u_name intrinsic in dimension %d:"
-			       " is %ld, should be %ld", n + 1,
+			       " u_name intrinsic in dimension %ld:"
+			       " is %ld, should be %ld", (long int) n + 1,
 			       (long int) mask_extent, (long int) array_extent);
 	    }
 	}
@@ -430,7 +431,7 @@ void
 	  ret_rank = GFC_DESCRIPTOR_RANK (retarray);
 	  if (ret_rank != 1)
 	    runtime_error ("rank of return array in u_name intrinsic"
-			   " should be 1, is %d", ret_rank);
+			   " should be 1, is %ld", (long int) ret_rank);
 
 	  ret_extent = retarray->dim[0].ubound + 1 - retarray->dim[0].lbound;
 	    if (ret_extent != rank)
-- 
GitLab