------- Comment #1 from evan dot fishbein at jpl dot nasa dot gov  2009-08-20 
04:11 -------
(In reply to comment #0)
> The following code segment
> 
> program scr
>   type S1
>      real, dimension(:), pointer :: P           ! NLEV
>      real, dimension(:), pointer :: t           ! NLEV
>   end type S1
> 
>   type S0
>      real, dimension(:), pointer :: P           ! NLEV
>   end type S0
> 
>   type (S0) :: x0
>   type (S1) :: x1
>   write (*,*)  'x0%P', associated(x0%P)
>   allocate(x0%P(20))
>   write (*,*)  'x0%P', associated(x0%P)
> 
>   write (*,*)  'x1%P', associated(x1%P)
>   allocate(x1%P(20))
>   write (*,*)  'x1%P', associated(x1%P)
> 
>  if (associated(x11%P)) deallocate(x11%P)
> end program scr
> 
> compiled under gfortran:
> 
> gfortran -o scr scr.f90 ; scr
>  x0%P F
>  x0%P T
>  x1%P T
>  x1%P T
> *** glibc detected *** double free or corruption (out): 0x0000000000400bc0 ***
> Abort
> 
> compiled using the absoft compiler
> /opt/absoft/bin/f90 -o scr scr.f90 ; scr
>  x0%P F
>  x0%P T
>  x1%P F
>  x1%P T
> 
> The textbook "Fortran 90 programing,  Ellis et al" says that the absoft
> compiler is producing the correct answer -- the gfortran is not.  Generally 
> the
> compiler is misinterpreting types containing multiple pointers. attempts to
> deallocate a pointer returned as associated produces an error
> 

There is a missing line in the code above:

type (S1) :: x11


-- 


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

Reply via email to