From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9574 invoked by alias); 10 Jan 2012 23:56:24 -0000 Received: (qmail 9565 invoked by uid 22791); 10 Jan 2012 23:56:24 -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; Tue, 10 Jan 2012 23:56:11 +0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/50981] [4.4/4.5/4.6 Regression] Wrong-code for scalarizing ELEMENTAL call with absent OPTIONAL argument Date: Tue, 10 Jan 2012 23:56: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: ASSIGNED X-Bugzilla-Priority: P4 X-Bugzilla-Assigned-To: mikael at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.4.7 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" 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-01/txt/msg01134.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50981 --- Comment #17 from Tobias Burnus 2012-01-10 23:54:50 UTC --- (In reply to comment #16) > This patch passes gfortran.dg/*elemental*, but fails on > gfortran.dg/class_array_{1,2,3,7,9}.f03. The problem is the way _copy is translated. One currently has in trans-stmt.c's gfc_trans_allocate /* Do a polymorphic deep copy. */ actual->next->expr->ts.type = BT_CLASS; gfc_add_data_component (actual->next->expr); This adds "class._data". With the patch of comment 16 one has now additionally in trans-expr.c's gfc_conv_procedure_call: + if (fsym && fsym->ts.type == BT_DERIVED && e->ts.type == BT_CLASS) + parmse.expr = gfc_class_data_get (parmse.expr); If one removes the latter it works. I think the proper solution is to remove the trans-stmt.c manual scalarization and handle somewhere in trans-{array,expr}.c the array bounds. Stupid attempts fail for various reasons: Changing the BT_CLASS to BT_DERIVED in gfc_trans_allocate does not work as one the offsets will no longer be class._size (why?). Keeping BT_CLASS but removing the gfc_add_data_component in trans-stmt.c will ICE for dataref - and removing that as well will lead to valid code with class._size, but without scalarization loop ...