public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Harald Anlauf <anlauf@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-3043] Fortran - use temporary char buffer for passing HOST_WIDE_INT to gfc_error
Date: Fri, 20 Aug 2021 11:38:32 +0000 (GMT)	[thread overview]
Message-ID: <20210820113832.3E1F6385781D@sourceware.org> (raw)

https://gcc.gnu.org/g:12f22906d3c025e7edb60e3264dc9cd27a49e3e1

commit r12-3043-g12f22906d3c025e7edb60e3264dc9cd27a49e3e1
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Fri Aug 20 13:38:00 2021 +0200

    Fortran - use temporary char buffer for passing HOST_WIDE_INT to gfc_error
    
    gcc/fortran/ChangeLog:
    
            PR fortran/100950
            * simplify.c (substring_has_constant_len): Fix format string of
            gfc_error, pass HOST_WIDE_INT bounds values via char buffer.

Diff:
---
 gcc/fortran/simplify.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index 492867e12cb..eaabbffca4d 100644
--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -4552,11 +4552,12 @@ substring_has_constant_len (gfc_expr *e)
 
   if (istart <= iend)
     {
+      char buffer[21];
       if (istart < 1)
 	{
-	  gfc_error ("Substring start index (" HOST_WIDE_INT_PRINT_DEC
-		     ") at %L below 1",
-		     istart, &ref->u.ss.start->where);
+	  sprintf (buffer, HOST_WIDE_INT_PRINT_DEC, istart);
+	  gfc_error ("Substring start index (%s) at %L below 1",
+		     buffer, &ref->u.ss.start->where);
 	  return false;
 	}
 
@@ -4567,9 +4568,9 @@ substring_has_constant_len (gfc_expr *e)
 	length = gfc_mpz_get_hwi (ref->u.ss.length->length->value.integer);
       if (iend > length)
 	{
-	  gfc_error ("Substring end index (" HOST_WIDE_INT_PRINT_DEC
-		     ") at %L exceeds string length",
-		     iend, &ref->u.ss.end->where);
+	  sprintf (buffer, HOST_WIDE_INT_PRINT_DEC, iend);
+	  gfc_error ("Substring end index (%s) at %L exceeds string length",
+		     buffer, &ref->u.ss.end->where);
 	  return false;
 	}
       length = iend - istart + 1;


                 reply	other threads:[~2021-08-20 11:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210820113832.3E1F6385781D@sourceware.org \
    --to=anlauf@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).