From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23224 invoked by alias); 3 Nov 2011 17:12:40 -0000 Received: (qmail 23214 invoked by uid 22791); 3 Nov 2011 17:12:39 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 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; Thu, 03 Nov 2011 17:12:20 +0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/50981] [4.4/4.5/4.6/4.7 Regression] Wrong-code for scalarizing ELEMENTAL call with absent OPTIONAL argument Date: Thu, 03 Nov 2011 17:12: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: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.4.7 X-Bugzilla-Changed-Fields: Target Milestone 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-11/txt/msg00301.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50981 Tobias Burnus changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |4.4.7 --- Comment #2 from Tobias Burnus 2011-11-03 17:12:15 UTC --- (In reply to comment #1) > No bootstraped compiler at hand; does this work? Does not help. (Nit: in trans-array.c "se.want..." instead of "se->".) Now the segfaults already for "ff" where the "b" argument is present. The segfault occurs at ELEMENTAL REAL(KIND=8) FUNCTION gg(a,b) ... IF(PRESENT(b)) THEN b1=b ! <<< here While "ff" now looks reasonable: ff (real(kind=8) & restrict a, integer(kind=4) * b) integer(kind=4) * D.1747; D.1747 = b; val.0 = gg (&ac[S.1 + -1], D.1747) + val.0; one has an issue with the call: rr[S.5 + -1] = ff (&aa[S.5 + -1], 1); as it is probably not a good idea to dereference the literal "1", unless you really want to access the memory address 0x1 ... * * * Works: 4.4.5 20100627 (prerelease) [gcc-4_4-branch revision 161471] Fails: 4.4.5 20100627 (prerelease) [gcc-4_4-branch revision 161472] Unless I made a mistake with building those versions, the regression is caused by: Rev. 161472 (PR fortran/43841 and PR 43843). http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161472 * trans-expr.c (gfc_conv_expr): Supply an address expression for GFC_SS_REFERENCE. (gfc_conv_expr_reference): Call gfc_conv_expr and return for GFC_SS_REFERENCE. * trans-array.c (gfc_add_loop_ss_code): Store the value rather than the address of a GFC_SS_REFERENCE. * trans.h : Change comment on GFC_SS_REFERENCE.