public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/40850]  New: "double free or corruption" returning derived types with allocatable components
@ 2009-07-24 19:35 mrestelli at gmail dot com
  2009-12-06 18:15 ` [Bug fortran/40850] double free in nested " dfranke at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 16+ messages in thread
From: mrestelli at gmail dot com @ 2009-07-24 19:35 UTC (permalink / raw)
  To: gcc-bugs

The attached code produces an error at runtime:

System:
Linux 2.6.27-gentoo-r8 x86_64 AMD Turion(tm) 64 Mobile Technology ML-32
AuthenticAMD GNU/Linux

$ gfortran bug.f90 -o bug

$ ./bug
*** glibc detected *** ./bug: double free or corruption (fasttop):
0x000000000060a5b0 ***
======= Backtrace: =========
/lib/libc.so.6[0x7f516d97a468]
/lib/libc.so.6(cfree+0x76)[0x7f516d97bfa6]
./bug[0x40272a]
./bug[0x40283c]
/lib/libc.so.6(__libc_start_main+0xe6)[0x7f516d9255c6]
./bug[0x4007b9]
[...]
Aborted



module mod_all

 implicit none

 public :: &
   t2, new2, operator(+)

 private

 type t1
   integer :: n1
   integer, allocatable :: d1(:)
 end type t1

 type t2
   integer :: n2
   type(t1), allocatable :: d2(:)
 end type t2

 interface operator(+)
   module procedure add
 end interface

 interface new2
   module procedure new2, new2_2
 end interface 

contains

!-----------------------------------------------------------------------

 pure function new1(d1) result(m)
  integer, intent(in) :: d1(:)
  type(t1) :: m

   m%n1 = size(d1)
   allocate(m%d1(m%n1))
   m%d1 = d1

 end function new1

!-----------------------------------------------------------------------

 pure function new2(d2) result(p)
  type(t1), intent(in) :: d2(:)
  type(t2) :: p

   p%n2 = size(d2)
   allocate(p%d2(p%n2))
   p%d2 = d2

 end function new2

!-----------------------------------------------------------------------

 pure function new2_2() result(p)
  type(t2) :: p

   p = new2( (/ new1((/1,1/)) /) )
 end function new2_2

!-----------------------------------------------------------------------

 elemental function add(p1,p2) result(p)
  type(t2), intent(in) :: p1,p2
  type(t2) :: p

   p = new2((/ p1%d2 , p2%d2 /))

 end function add

!-----------------------------------------------------------------------

end module mod_all

!-----------------------------------------------------------------------

program a_main

 use mod_all

 type(t2) :: q(3)

  q(1) = new2()
  q(2) = new2()

  q(3) = q(2) + q(1)

end program a_main


-- 
           Summary: "double free or corruption" returning derived types with
                    allocatable components
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mrestelli at gmail dot com
 GCC build triplet: gcc version 4.5.0 20090724
  GCC host triplet: Linux 2.6.27-gentoo-r8 x86_64 AMD
GCC target triplet: x86_64-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40850


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

end of thread, other threads:[~2012-10-06 21:26 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-40850-4@http.gcc.gnu.org/bugzilla/>
2010-12-28 22:56 ` [Bug fortran/40850] double free in nested types with allocatable components dfranke at gcc dot gnu.org
2011-02-21  7:56 ` burnus at gcc dot gnu.org
2011-02-21 13:02 ` mikael at gcc dot gnu.org
2011-02-21 13:04 ` mikael at gcc dot gnu.org
2011-02-23 23:08 ` mikael at gcc dot gnu.org
2012-04-26 14:04 ` janus at gcc dot gnu.org
2012-06-06 20:20 ` b.w.barker at gmail dot com
2012-06-06 20:58 ` janus at gcc dot gnu.org
2012-06-09 22:49 ` b.w.barker at gmail dot com
2012-10-06 21:26 ` janus at gcc dot gnu.org
2009-07-24 19:35 [Bug fortran/40850] New: "double free or corruption" returning derived " mrestelli at gmail dot com
2009-12-06 18:15 ` [Bug fortran/40850] double free in nested " dfranke at gcc dot gnu dot org
2009-12-07 21:01 ` janus at gcc dot gnu dot org
2010-01-07 14:49 ` pault at gcc dot gnu dot org
2010-01-29 18:24 ` mrestelli at gmail dot com
2010-02-12 13:51 ` domob at gcc dot gnu dot org
2010-03-07 17:24 ` dominiq at lps dot ens dot fr

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).