public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "fxcoudert at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/29067] Internal Error: gfc_resolve_expr(): Bad expression type
Date: Mon, 30 Oct 2006 16:46:00 -0000	[thread overview]
Message-ID: <20061030164622.22276.qmail@sourceware.org> (raw)
In-Reply-To: <bug-29067-13243@http.gcc.gnu.org/bugzilla/>



------- Comment #17 from fxcoudert at gcc dot gnu dot org  2006-10-30 16:46 -------
The following patch fixes the problem:

Index: data.c
===================================================================
--- data.c      (revision 118134)
+++ data.c      (working copy)
@@ -155,7 +155,8 @@
       init->expr_type = EXPR_CONSTANT;
       init->ts = *ts;

-      dest = gfc_getmem (len);
+      dest = gfc_getmem (len + 1);
+      dest[len] = '\0';
       init->value.character.length = len;
       init->value.character.string = dest;
       /* Blank the string if we're only setting a substring.  */
Index: decl.c
===================================================================
--- decl.c      (revision 118134)
+++ decl.c      (working copy)
@@ -753,10 +753,11 @@
   slen = expr->value.character.length;
   if (len != slen)
     {
-      s = gfc_getmem (len);
+      s = gfc_getmem (len + 1);
       memcpy (s, expr->value.character.string, MIN (len, slen));
       if (len > slen)
        memset (&s[slen], ' ', len - slen);
+      s[len] = '\0';
       gfc_free (expr->value.character.string);
       expr->value.character.string = s;
       expr->value.character.length = len;
Index: expr.c
===================================================================
--- expr.c      (revision 118134)
+++ expr.c      (working copy)
@@ -1438,7 +1438,7 @@
          gfc_extract_int (p->ref->u.ss.end, &end);
          s = gfc_getmem (end - start + 1);
          memcpy (s, p->value.character.string + start, end - start);
-         s[end] = '\0';  /* TODO: C-style string for debugging.  */
+         s[end-start+1] = '\0';  /* TODO: C-style string for debugging.  */
          gfc_free (p->value.character.string);
          p->value.character.string = s;
          p->value.character.length = end - start;


Before submitting it, I'd like to audit the rest of the front-end code for
problems similar to those in decl.c and data.c.


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |fxcoudert at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
           Keywords|                            |patch
   Last reconfirmed|2006-10-17 13:01:41         |2006-10-30 16:46:22
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29067


  parent reply	other threads:[~2006-10-30 16:46 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-13 20:10 [Bug fortran/29067] New: " mathieu dot courtois at free dot fr
2006-09-13 20:17 ` [Bug fortran/29067] " kargl at gcc dot gnu dot org
2006-09-13 20:18 ` mathieu dot courtois at free dot fr
2006-09-13 21:42 ` kargl at gcc dot gnu dot org
2006-09-13 21:44 ` kargl at gcc dot gnu dot org
2006-09-14  9:05 ` mathieu dot courtois at free dot fr
2006-09-14  9:08 ` mathieu dot courtois at free dot fr
2006-10-12 12:18 ` pault at gcc dot gnu dot org
2006-10-12 14:13 ` sgk at troutmask dot apl dot washington dot edu
2006-10-13  7:39 ` fxcoudert at gcc dot gnu dot org
2006-10-13  7:54 ` fxcoudert at gcc dot gnu dot org
2006-10-15  1:21 ` kargl at gcc dot gnu dot org
2006-10-15  1:53 ` kargl at gcc dot gnu dot org
2006-10-15  8:40 ` fxcoudert at gcc dot gnu dot org
2006-10-16 21:28 ` mathieu dot courtois at free dot fr
2006-10-17 12:43 ` pault at gcc dot gnu dot org
2006-10-17 13:01 ` fxcoudert at gcc dot gnu dot org
2006-10-30 16:46 ` fxcoudert at gcc dot gnu dot org [this message]
2006-10-31 20:15 ` fxcoudert at gcc dot gnu dot org
2006-11-03 12:29 ` [Bug fortran/29067] [4.1/4.2 only] " fxcoudert at gcc dot gnu dot org
2006-11-03 14:26 ` fxcoudert at gcc dot gnu dot org
2006-11-03 14:28 ` [Bug fortran/29067] " fxcoudert at gcc dot gnu dot org
2006-11-30 19:26 ` chaoyingfu at gcc dot gnu dot org

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=20061030164622.22276.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).