[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc-fortran
Subject:    [patch, libfortran] Bug 65596 - [4.9,5.0 Regression] NAMELIST bug with f2003: reads too far
From:       Jerry DeLisle <jvdelisle () charter ! net>
Date:       2015-03-28 1:18:26
Message-ID: 55160162.7010600 () charter ! net
[Download RAW message or body]

At first glance this looked like only a regression in 4.9.  While searching for 
the regression I noticed an error in unit.c (probably a copy/paste error). Upon 
correcting that obvious error, the regression found in 4.9 also appeared in 5.0.

The fix is simple and obvious and I have regression tested on 4.9 and 5.0.

I will commit in the next few days, giving others a chance to review.

New test case attached. I used STOP rather than abort just to change things up a 
bit if the case fails. (yes I could have used -fall-intrinsics)

Regards

Jerry

2015-03-27 Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/65596
	* io/transfer.c (data_transfer_init): If in namelist mode and
	delimiter is not specified, set it to DELIM_QUOTE, independent
	of -std.
	* io/unit.c (init_units): Set flags.delim to the correct
	initial value of DELIM_UNSPECIFIED.




["pr65596.diff" (text/x-patch)]

Index: io/transfer.c
===================================================================
--- io/transfer.c	(revision 221744)
+++ io/transfer.c	(working copy)
@@ -2675,8 +2675,7 @@ data_transfer_init (st_parameter_dt *dtp, int read
   if (dtp->u.p.current_unit->delim_status == DELIM_UNSPECIFIED)
     {
       if (ionml && dtp->u.p.current_unit->flags.delim == DELIM_UNSPECIFIED)
-	dtp->u.p.current_unit->delim_status =
-	  compile_options.allow_std & GFC_STD_GNU ? DELIM_QUOTE : DELIM_NONE;
+	dtp->u.p.current_unit->delim_status = DELIM_QUOTE;
       else
 	dtp->u.p.current_unit->delim_status = dtp->u.p.current_unit->flags.delim;
     }
Index: io/unit.c
===================================================================
--- io/unit.c	(revision 221744)
+++ io/unit.c	(working copy)
@@ -608,7 +608,7 @@ init_units (void)
       u->flags.position = POSITION_ASIS;
       u->flags.sign = SIGN_SUPPRESS;
       u->flags.decimal = DECIMAL_POINT;
-      u->flags.delim = DECIMAL_UNSPECIFIED;
+      u->flags.delim = DELIM_UNSPECIFIED;
       u->flags.encoding = ENCODING_DEFAULT;
       u->flags.async = ASYNC_NO;
       u->flags.round = ROUND_UNSPECIFIED;

["pr65596.f90" (text/x-fortran)]

! { dg-do run }
! { dg-options "-std=f2003 -fall-intrinsics" }
! PR65596 Namelist reads too far.
integer ,parameter :: CL=80
integer ,parameter :: AL=4

character(CL) :: mode
character(CL) :: cats(AL)
character(CL) :: dogs(AL)
character(CL) :: rslt(AL)
integer       :: ierr, k

namelist / theList / cats, dogs, mode

open(27,status="scratch")

write(27,'(A)')  "&theList"
write(27,'(A)')  " mode      = 'on'"
write(27,'(A)')  " dogs      = 'Rover',"
write(27,'(A)')  "             'Spot'"
write(27,'(A)')  " cats      = 'Fluffy',"
write(27,'(A)')  "             'Hairball'"
write(27,'(A)') "/"
rewind(27)

mode    = 'off'
cats(:) = '________'
dogs(:) = '________'

read (27, nml=theList, iostat=ierr)

if (ierr .ne. 0) call abort

rslt = ['Rover   ','Spot    ','________','________']
if (any(dogs.ne.rslt)) call abort

rslt = ['Fluffy  ','Hairball','________','________']
if (any(cats.ne.rslt)) call abort

close(27)

contains

subroutine abort()
  close(27)
  stop 500
end subroutine abort

end


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic