public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/61281] New: Memory corruption on assigning a polymorphic variable to a non-polymorphic one
@ 2014-05-22  4:11 rouson at stanford dot edu
  2014-05-23 15:18 ` [Bug fortran/61281] " dominiq at lps dot ens.fr
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: rouson at stanford dot edu @ 2014-05-22  4:11 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-12-14 12:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-22  4:11 [Bug fortran/61281] New: Memory corruption on assigning a polymorphic variable to a non-polymorphic one rouson at stanford dot edu
2014-05-23 15:18 ` [Bug fortran/61281] " dominiq at lps dot ens.fr
2014-05-23 20:48 ` rouson at stanford dot edu
2014-05-23 21:00 ` dominiq at lps dot ens.fr
2014-06-01  9:44 ` dominiq at lps dot ens.fr
2014-12-14  9:43 ` janus at gcc dot gnu.org
2014-12-14 10:24 ` dominiq at lps dot ens.fr
2014-12-14 12:13 ` janus at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).