public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jvdelisle at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/31251] Non-integer character length leads to segfault
Date: Fri, 04 May 2007 06:39:00 -0000	[thread overview]
Message-ID: <20070504063905.1193.qmail@sourceware.org> (raw)
In-Reply-To: <bug-31251-10259@http.gcc.gnu.org/bugzilla/>



------- Comment #10 from jvdelisle at gcc dot gnu dot org  2007-05-04 07:39 -------
Comment #9 is a red herring.  Using gdb and looking at this at line 2143:

     mpz_set (result->value.integer, e->ts.cl->length->value.integer);

(gdb) p *e->ts.cl->length
$9 = {expr_type = EXPR_CONSTANT, ts = {type = BT_REAL, kind = 4, 
    derived = 0x0, cl = 0x0}, rank = 0, shape = 0x0, symtree = 0x0, ref = 0x0, 
  where = {nextc = 0xef3b0c "2.3) :: s", lb = 0xef3ae0}, from_H = 0, 
  inline_noncopying_intrinsic = 0, con_by_offset = 0x0, value = {logical = 24, 
    integer = {{_mp_alloc = 24, _mp_size = 0, _mp_d = 0x1}}, real = {{
        _mpfr_prec = 24, _mpfr_sign = 1, _mpfr_exp = 2, _mpfr_d = 0xf25d08}}, 
    complex = {r = {{_mpfr_prec = 24, _mpfr_sign = 1, _mpfr_exp = 2, 
          _mpfr_d = 0xf25d08}}, i = {{_mpfr_prec = 0, _mpfr_sign = 0, 
          _mpfr_exp = 0, _mpfr_d = 0x0}}}, op = {operator = 24, uop = 0x1, 
      op1 = 0x2, op2 = 0xf25d08}, function = {actual = 0x18, 
      name = 0x1 <Address 0x1 out of bounds>, isym = 0x2, esym = 0xf25d08}, 
    character = {length = 24, string = 0x1 <Address 0x1 out of bounds>}, 
    constructor = 0x18}}

The type is real and we are trying to use the value.integer which is probably
meaningless.  Again, I am unable to really test this, but here is a suggestion:

Index: simplify.c
===================================================================
--- simplify.c  (revision 124405)
+++ simplify.c  (working copy)
@@ -2136,14 +2136,15 @@ gfc_simplify_len (gfc_expr *e)
     }

   if (e->ts.cl != NULL && e->ts.cl->length != NULL
-      && e->ts.cl->length->expr_type == EXPR_CONSTANT)
+      && e->ts.cl->length->expr_type == EXPR_CONSTANT
+      && e->ts.cl->length->ts.type == BT_INTEGER)
     {
       result = gfc_constant_result (BT_INTEGER, gfc_default_integer_kind,
                                    &e->where);
       mpz_set (result->value.integer, e->ts.cl->length->value.integer);
       return range_check (result, "LEN");
     }
-  
+
   return NULL;
 }


-- 


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


  parent reply	other threads:[~2007-05-04  6:39 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-17 21:46 [Bug fortran/31251] New: " fxcoudert at gcc dot gnu dot org
2007-03-17 21:46 ` [Bug fortran/31251] " fxcoudert at gcc dot gnu dot org
2007-04-07 16:06 ` tobi at gcc dot gnu dot org
2007-04-29 22:41 ` jvdelisle at gcc dot gnu dot org
2007-04-29 23:54 ` jvdelisle at gcc dot gnu dot org
2007-05-01 13:47 ` jvdelisle at gcc dot gnu dot org
2007-05-02  3:13 ` jvdelisle at gcc dot gnu dot org
2007-05-03 14:49 ` fxcoudert at gcc dot gnu dot org
2007-05-04  2:27 ` jvdelisle at gcc dot gnu dot org
2007-05-04  5:17 ` kargl at gcc dot gnu dot org
2007-05-04  5:42 ` jvdelisle at gcc dot gnu dot org
2007-05-04  6:39 ` jvdelisle at gcc dot gnu dot org [this message]
2007-05-04  9:44 ` fxcoudert at gcc dot gnu dot org
2007-05-04 11:10 ` fxcoudert at gcc dot gnu dot org
2007-05-04 13:36 ` jvdelisle at gcc dot gnu dot org
2007-05-05  2:50 ` jvdelisle at gcc dot gnu dot org
2007-05-05  7:40 ` jvdelisle at gcc dot gnu dot org
2007-05-05 18:45 ` patchapp at dberlin dot org
2007-05-06  4:11 ` jvdelisle at gcc dot gnu dot org
2007-05-06  4:11 ` jvdelisle 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=20070504063905.1193.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).