This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[patch, libgfortran] PR36582 Namelist I/O error: Bogus "Cannot match namelist object"
- From: Jerry DeLisle <jvdelisle at verizon dot net>
- To: Fortran List <fortran at gcc dot gnu dot org>
- Cc: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 22 Jul 2008 21:28:53 -0700
- Subject: [patch, libgfortran] PR36582 Namelist I/O error: Bogus "Cannot match namelist object"
Hi all,
I will commit this patch as simple, though not obvious at all. I figured it out
with gdb when I observed the correct node was being found, but the pointer was
being modified before reading the data.
Regression tested on x86-64.
I think this is a candidate for back port to 4.3 which I will do in a few days
if no objections.
Test case attached.
Regards,
Jerry
2008-07-22 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/36852
* io/list_read.c: If variable rank is zero, do not adjust the found
namelist object pointer.
Index: io/list_read.c
===================================================================
--- io/list_read.c (revision 138071)
+++ io/list_read.c (working copy)
@@ -2791,7 +2791,7 @@ get_name:
if (nl->type == GFC_DTYPE_DERIVED)
nml_touch_nodes (nl);
- if (component_flag)
+ if (component_flag && nl->var_rank > 0)
nl = first_nl;
/* Make sure no extraneous qualifiers are there. */
! { dg-do run }
! PR36582 Namelist I/O error: Bogus "Cannot match namelist object"
! Test case derived from PR.
module mod1
type screen_io_type
integer :: begin
end type screen_io_type
type adjoint_type
type(screen_io_type) :: screen_io_fs_ntime
character(12) :: solver_type
end type adjoint_type
type(adjoint_type) :: adjoint
namelist/info_adjoint/adjoint
end module mod1
program gfortran_error_2
use mod1
adjoint%solver_type = "abcdefghijkl"
open(31,status='scratch')
write(31, '(a)') "&info_adjoint"
write(31, '(a)') "adjoint%solver_type = 'direct'"
write(31, '(a)') "adjoint%screen_io_fs_ntime%begin = 42"
write(31, '(a)') "/"
rewind(31)
read(31,nml=info_adjoint)
if (adjoint%solver_type /= 'direct') call abort
if (adjoint%screen_io_fs_ntime%begin /= 42) call abort
end program gfortran_error_2