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/50163] [4.3/4.4/4.5/4.6/4.7 Regression] ICE: initialization expression
Date: Tue, 23 Aug 2011 12:14:00 -0000	[thread overview]
Message-ID: <bug-50163-4-LDkCQUHqxb@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-50163-4@http.gcc.gnu.org/bugzilla/>

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-invalid-code
                 CC|                            |burnus at gcc dot gnu.org
      Known to work|                            |4.1.2
   Target Milestone|---                         |4.6.2
            Summary|Internal compiler error:    |[4.3/4.4/4.5/4.6/4.7
                   |initialization expression   |Regression] ICE:
                   |                            |initialization expression
      Known to fail|                            |4.3.4, 4.5.3, 4.6.1, 4.7.0

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-08-23 10:37:38 UTC ---
That's actually a regression: With 4.1.2 I get:

  integer :: iloc=index(xx,'bb')
                       1
  Error: Parameter 'xx' at (1) has not been declared or is a variable,
  which does not reduce to a constant expression

While with GCC 4.3.4 and later, I get an ICE. I have not tested 4.2.

 * * *

The problem seems to be the delayed error output. In expr.c's check_init_expr,
one has:

        if ((m = check_conversion (e)) == MATCH_NO
            && (m = check_inquiry (e, 1)) == MATCH_NO
            && (m = check_null (e)) == MATCH_NO
            && (m = check_transformational (e)) == MATCH_NO
            && (m = check_elemental (e)) == MATCH_NO)
          {
            gfc_error ("Intrinsic function '%s' at %L is not permitted "
                       "in an initialization expression",
                       e->symtree->n.sym->name, &e->where);
            m = MATCH_ERROR;
          }

        /* Try to scalarize an elemental intrinsic function that has an
           array argument.  */
        isym = gfc_find_function (e->symtree->n.sym->name);
        if (isym && isym->elemental
            && (t = scalarize_intrinsic_call (e)) == SUCCESS)


What happens now is: "check_elemental" prints an error (which gets buffered)
and returns MATCH_ERROR. However, that value is not checked - thus the code
continues to the scalarize_intrinsic_call(e), which then gives an ICE.


Draft patch (only very lightly tested):

--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -2481,6 +2481,9 @@ check_init_expr (gfc_expr *e)
            m = MATCH_ERROR;
          }

+       if (m == MATCH_ERROR)
+         return FAILURE;
+
        /* Try to scalarize an elemental intrinsic function that has an
           array argument.  */
        isym = gfc_find_function (e->symtree->n.sym->name);


  parent reply	other threads:[~2011-08-23 10:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-23  9:41 [Bug fortran/50163] New: Internal compiler error: " pmason at ricardo dot com
2011-08-23 10:21 ` [Bug fortran/50163] " dominiq at lps dot ens.fr
2011-08-23 12:14 ` burnus at gcc dot gnu.org [this message]
2011-08-24 13:26 ` [Bug fortran/50163] [4.3/4.4/4.5/4.6/4.7 Regression] ICE: " burnus at gcc dot gnu.org
2011-08-24 14:02 ` jakub at gcc dot gnu.org
2011-08-25  8:33 ` burnus at gcc dot gnu.org
2011-08-30  7:26 ` [Bug fortran/50163] [4.4/4.5 " burnus at gcc dot gnu.org
2011-08-30 12:24 ` [Bug fortran/50163] [4.4/4.5/4.6/4.7 " 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-50163-4-LDkCQUHqxb@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).