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



kargl at gcc dot gnu.org changed:



           What    |Removed                     |Added

----------------------------------------------------------------------------

                 CC|                            |kargl at gcc dot gnu.org



--- Comment #7 from kargl at gcc dot gnu.org 2013-01-04 16:58:36 UTC ---

(In reply to comment #6)

> Another manifestation of this problem is with type extension.  Here is another

> small example which fails.  (Tested on v4.6.3 and also a 1/4/2013 snapshot of

> the 4.8 trunk.):

> 

> program test_type_extension

> 

>   type t1_t

>      real :: x

>   end type t1_t

> 

>   type, extends(t1_t) :: t1e_t

>      character(8) :: string

>   end type t1e_t

> 

>   type(t1e_t) :: t1e

> 

>   integer :: answer

>   namelist /test_NML/ t1e, answer

> 

>   open(unit=1,file='test1.inp')

>   read(1,NML=test_NML)

> 

>   write(*,*) t1e%x, t1e%string, answer

> 

> end program test_type_extension

> 

> File test1.inp contains:

> 

> &test_NML

> t1e%x = 2.,t1e%string='gfortran',answer=42

> /

> 

> wws@w6ws-4:~/fortran/xxx$ gfortran namelist.f90

> wws@w6ws-4:~/fortran/xxx$ a.out

> At line 17 of file namelist.f90 (unit = 1, file = 'test1.inp')

> Fortran runtime error: Cannot match namelist object name %x



If one modifies your code to have gfortran create the file 

with the namelist, it can then read it back.  Here's what I

have

program test_type_extension



  type t1_t

     real :: x

  end type t1_t



  type, extends(t1_t) :: t1e_t

     character(8) :: string

  end type t1e_t



  type(t1e_t) :: t1e



  integer :: answer

  namelist /test_NML/ t1e, answer



  t1e%x = 2.

  t1e%string='gfortran'

  answer=42



  open(unit=2,file='test2.inp')

  write(2,NML=test_NML)

  close(2)



  t1e%x = 0

  t1e%string=''

  answer=0



  open(unit=2,file='test2.inp')

  read(2,NML=test_NML)

  close(2)



  write(*,*) t1e%x, t1e%string, answer



  open(unit=1,file='test1.inp')

  read(1,NML=test_NML)



  write(*,*) t1e%x, t1e%string, answer



end program test_type_extension



% gfc4x -o z foo.f90 && ./z

   2.00000000     gfortran          42

At line 36 of file foo.f90 (unit = 1, file = 'test1.inp')

Fortran runtime error: Cannot match namelist object name %x



% cat test2.inp 

&TEST_NML

 T1E%T1_T%X=  2.00000000    ,

 T1E%STRING="gfortran",

 ANSWER=         42,

 /



It appears that gfortran's handling of an extended

derived type in its namelist code is incorrect.

Reply via email to