From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29890 invoked by alias); 28 Nov 2012 14:54:49 -0000 Received: (qmail 29782 invoked by uid 48); 28 Nov 2012 14:54:34 -0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/55501] [F03] ICE using MERGE in constant expr Date: Wed, 28 Nov 2012 14:54: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-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: janus at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: 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" Content-Transfer-Encoding: quoted-printable 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: 2012-11/txt/msg02745.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D55501 --- Comment #12 from Tobias Burnus 2012-11-28 1= 4:54:33 UTC --- (In reply to comment #10) > integer :: i(-1:1) =3D 0 > print *, lbound(merge(i,i,.true.)) > Without the patch, this prints: > 1 > And with the patch: > -1 Makes perfectly sense: For "lbound(array,dim)": "If ARRAY is a whole array = and either ARRAY is an assumed-size array of rank DIM or dimension DIM of ARRAY= has nonzero extent, LBOUND (ARRAY, DIM) has a value equal to the lower bound for subscript DIM of ARRAY. Otherwise the result value is 1." With "whole array array component or array name without further quali=0Cca= tion (6.5.2)" Thus "lbound(i)" is a whole-array, "lbound(i(:))" or "lbound(merge(i,i,.tru= e))" is not. I think the simplest it to replace "lbound (merge(i,i,.true.)" by "lbound( = (i) )" [e->expr_type =3D EXPR_OP && e->value.op.op =3D=3D INTRINSIC_PARENTHESES= ]. Possibly only if expr_type =3D=3D EXPR_VARIABLE as otherwise the INTRINSIC_PARENTHESES will hamper further optimization (unless -fno-protect-parens).