public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/49023] ICE on invalid code with C_ASSOCIATED
Date: Wed, 18 May 2011 16:55:00 -0000	[thread overview]
Message-ID: <bug-49023-4-LcSvuaRxYw@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-49023-4@http.gcc.gnu.org/bugzilla/>

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu.org

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-05-18 16:09:54 UTC ---
==31261== Invalid read of size 8
==31261==    at 0x510673: gfc_resolve_expr (resolve.c:2674)
==31261==    by 0x50E37C: resolve_code (resolve.c:9026)

That's at first "if" block gfc_iso_c_func_interface. In this example, one has
expr_type == EXPR_ARRAY. I think the following patch should be OK (for F2003,
in F2008, the pointer returned by functions also counts as variable).

Additionally, one needs to add a check for the second argument; the program
crashes for
  C_ASSOCIATED(x,[y])
at gfc_conv_array_constructor_expr, at fortran/trans-expr.c:4120

--- resolve.c   (revision 173865)
+++ resolve.c   (working copy)
@@ -2666,9 +2666,8 @@ gfc_iso_c_func_interface (gfc_symbol *sy
   gfc_typespec *arg_ts;
   symbol_attribute arg_attr;

-  if (args->expr->expr_type == EXPR_CONSTANT
-      || args->expr->expr_type == EXPR_OP
-      || args->expr->expr_type == EXPR_NULL)
+  if (args->expr->expr_type != EXPR_VARIABLE
+      || args->expr->symtree->n.sym->attr.flavor != FL_VARIABLE)
     {
       gfc_error ("Argument to '%s' at %L is not a variable",
                 sym->name, &(args->expr->where));


  reply	other threads:[~2011-05-18 16:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-17 14:10 [Bug fortran/49023] New: " dennis.wassel at googlemail dot com
2011-05-18 16:55 ` burnus at gcc dot gnu.org [this message]
2013-03-25 15:54 ` [Bug fortran/49023] " burnus at gcc dot gnu.org
2013-03-25 17:51 ` burnus at gcc dot gnu.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=bug-49023-4-LcSvuaRxYw@http.gcc.gnu.org/bugzilla/ \
    --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).