From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18555 invoked by alias); 19 Oct 2012 20:34:05 -0000 Received: (qmail 17516 invoked by uid 48); 19 Oct 2012 20:33:49 -0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/54992] New: [OOP] Wrong offset in the array offset calculation when using nonclass%class(index)%nonclass Date: Fri, 19 Oct 2012 20:34:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new 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: --- X-Bugzilla-Changed-Fields: Message-ID: 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-10/txt/msg01790.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54992 Bug #: 54992 Summary: [OOP] Wrong offset in the array offset calculation when using nonclass%class(index)%nonclass Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned@gcc.gnu.org ReportedBy: burnus@gcc.gnu.org CC: janus@gcc.gnu.org, pault@gcc.gnu.org As reported by Andrew Benson in the thread starting at http://gcc.gnu.org/ml/fortran/2012-10/msg00087.html The problem is that gfortran generates the wrong code for: targetNode%cBh(2)%hostNode => targetNode where "cBh" is a polymorphic array. The offset is calculated as ((base_type *)targetNode->_data->cBh->_data)[ index ].host Instead of the proper: targetNode->_data->cBh->_data.data + (index * targetNode->_data->cBh->_vptr_size) Test case: http://gcc.gnu.org/ml/fortran/2012-10/msg00100.html Analysis: http://gcc.gnu.org/ml/fortran/2012-10/msg00101.html