From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24793 invoked by alias); 23 Aug 2011 10:38:24 -0000 Received: (qmail 24783 invoked by uid 22791); 23 Aug 2011 10:38:23 -0000 X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,RAZOR2_CHECK X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 23 Aug 2011 10:38:09 +0000 From: "burnus at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: ice-on-invalid-code X-Bugzilla-Severity: minor X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.6.2 X-Bugzilla-Changed-Fields: Keywords CC Known to work Target Milestone Summary Known to fail Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-08/txt/msg01908.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50163 Tobias Burnus 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 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);