From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9323 invoked by alias); 22 May 2014 04:11:30 -0000 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 Received: (qmail 9307 invoked by uid 48); 22 May 2014 04:11:26 -0000 From: "rouson at stanford dot edu" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/61281] New: Memory corruption on assigning a polymorphic variable to a non-polymorphic one Date: Thu, 22 May 2014 04:11: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-Version: 4.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rouson at stanford dot edu X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-05/txt/msg01906.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61281 Bug ID: 61281 Summary: Memory corruption on assigning a polymorphic variable to a non-polymorphic one Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: rouson at stanford dot edu The code below demonstrates a bug isolated from code from my collaborator Rob Rosenberg of the Naval Research Laboratory. The code exhibits an apparent memory corruption issue with gfortran 4.9 dated 20140416. Gfortran 4.8.2 rejects the code with the message below. Damian $ cat rob.f90 type employees character(3) :: name="rob" end type type companies type(employees) :: list end type type(companies) :: nrl print *,nrl%list call map print *,nrl%list contains type (employees) function give_raise(e) class(employees) :: e ! Switch to "type" to hide bug give_raise=e end function subroutine map() nrl%list=give_raise(nrl%list) end subroutine end $ gfortran rob.f90 $ ./a.out rob 8?? $ gfortran --version GNU Fortran (MacPorts gcc49 4.9-20140416_0) 4.9.0 20140416 (prerelease) Copyright (C) 2014 Free Software Foundation, Inc. $ sudo port select --set gcc mp-gcc48 Selecting 'mp-gcc48' for 'gcc' succeeded. 'mp-gcc48' is now active. $ gfortran rob.f90 rob.f90:14.15: give_raise=e 1 Error: Can't convert CLASS(employees) to TYPE(employees) at (1) localhost:Desktop rouson$ gfortran --version GNU Fortran (MacPorts gcc48 4.8.2_0) 4.8.2