https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105473

--- Comment #15 from harper at msor dot vuw.ac.nz ---
Thank you. My test program failed to distinguish some bad cases from good 
cases; a revised version of the program is below. The important change 
was making both elements of x be 666 just before both read statements, to 
allow checking whether anything was read as well as what. A cosmetic 
change was an explicit format called fmt instead of * when printing x etc.

! Does list-directed reading work properly with decimal='comma' ?
   implicit none
   real x(2)
   character(*),parameter:: punc = ",; .", fmt = '(A,2(F0.1,1X),A,I0)'
   integer,parameter:: lpunc =len(punc)
   integer ios,i,j
   character:: msg*80, input(lpunc**2)*4 = &
        [(("2"//punc(i:i)//"5"//punc(j:j),i=1,lpunc),j=1,lpunc)]

   do i = 1,size(input)
      print *,'i=',i,'input(i) = "',input(i),'"'
      x = 666
      read(input(i),*,decimal='point',iostat=ios,iomsg=msg) x
      print fmt,' with decimal=point x(:) =',x,' ios=',ios
!     if(ios/=0) print *,trim(msg)
      x = 666
      read(input(i),*,decimal='comma',iostat=ios,iomsg=msg) x
      print fmt,' with decimal=comma x(:) =',x,' ios=',ios
!     if(ios/=0) print *,trim(msg)
   end do
end program


On Mon, 16 May 2022, jvdelisle at gcc dot gnu.org wrote:

> Date: Mon, 16 May 2022 00:49:44 +0000
> From: jvdelisle at gcc dot gnu.org <gcc-bugzi...@gcc.gnu.org>
> To: John Harper <john.har...@vuw.ac.nz>
> Subject: [Bug fortran/105473] semicolon allowed when list-directed read
>     integer with decimal='point'
> Resent-Date: Mon, 16 May 2022 12:49:53 +1200 (NZST)
> Resent-From: <john.har...@vuw.ac.nz>
> 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105473
>
> --- Comment #13 from Jerry DeLisle <jvdelisle at gcc dot gnu.org> ---
> With John's multiple combinations test case I get the following results with
> the attached patch. All places where we gave an error before the patch, we 
> give
> errors now plus new errors
>
> $ gfc multi.f90
> $ ./a.out
> i=           1 input(i) = "2,5,"
> with decimal=point x(:) =   2.00000000       5.00000000      ios=           0
> with decimal=comma x(:) =   2.00000000       666.000000      ios=        5010
> i=           2 input(i) = "2;5,"
> with decimal=point x(:) =   2.00000000       666.000000      ios=        5010
> with decimal=comma x(:) =   2.00000000       5.00000000      ios=           0
> i=           3 input(i) = "2 5,"
> with decimal=point x(:) =   2.00000000       5.00000000      ios=           0
> with decimal=comma x(:) =   2.00000000       5.00000000      ios=           0
> i=           4 input(i) = "2.5,"
> with decimal=point x(:) =   2.50000000       5.00000000      ios=          -1
> with decimal=comma x(:) =   2.50000000       666.000000      ios=        5010
> i=           5 input(i) = "2,5;"
> with decimal=point x(:) =   2.00000000       5.00000000      ios=        5010
> with decimal=comma x(:) =   2.50000000       666.000000      ios=          -1
> i=           6 input(i) = "2;5;"
> with decimal=point x(:) =   2.00000000       666.000000      ios=        5010
> with decimal=comma x(:) =   2.00000000       5.00000000      ios=           0
> i=           7 input(i) = "2 5;"
> with decimal=point x(:) =   2.00000000       5.00000000      ios=        5010
> with decimal=comma x(:) =   2.00000000       5.00000000      ios=           0
> i=           8 input(i) = "2.5;"
> with decimal=point x(:) =   2.50000000       5.00000000      ios=        5010
> with decimal=comma x(:) =   2.50000000       666.000000      ios=          -1
> i=           9 input(i) = "2,5 "
> with decimal=point x(:) =   2.00000000       5.00000000      ios=           0
> with decimal=comma x(:) =   2.50000000       666.000000      ios=          -1
> i=          10 input(i) = "2;5 "
> with decimal=point x(:) =   2.00000000       666.000000      ios=        5010
> with decimal=comma x(:) =   2.00000000       5.00000000      ios=           0
> i=          11 input(i) = "2 5 "
> with decimal=point x(:) =   2.00000000       5.00000000      ios=           0
> with decimal=comma x(:) =   2.00000000       5.00000000      ios=           0
> i=          12 input(i) = "2.5 "
> with decimal=point x(:) =   2.50000000       5.00000000      ios=          -1
> with decimal=comma x(:) =   2.50000000       666.000000      ios=          -1
> i=          13 input(i) = "2,5."
> with decimal=point x(:) =   2.00000000       5.00000000      ios=           0
> with decimal=comma x(:) =   2.00000000       666.000000      ios=        5010
> i=          14 input(i) = "2;5."
> with decimal=point x(:) =   2.00000000       666.000000      ios=        5010
> with decimal=comma x(:) =   2.00000000       5.00000000      ios=           0
> i=          15 input(i) = "2 5."
> with decimal=point x(:) =   2.00000000       5.00000000      ios=           0
> with decimal=comma x(:) =   2.00000000       5.00000000      ios=           0
> i=          16 input(i) = "2.5."
> with decimal=point x(:) =   2.00000000       5.00000000      ios=        5010
> with decimal=comma x(:) =   2.00000000       666.000000      ios=        5010
> [jerry@amdr pr105473]$ gfc multi.f90
> [jerry@amdr pr105473]$ ./a.out
> i=           1 input(i) = "2,5,"
> with decimal=point x(:) =   2.00000000       5.00000000      ios=           0
> with decimal=comma x(:) =   2.00000000       666.000000      ios=        5010
> Bad real number in item 1 of list input
> i=           2 input(i) = "2;5,"
> with decimal=point x(:) =   2.00000000       666.000000      ios=        5010
> Semicolon not allowed as separator with DECIMAL='point'
> with decimal=comma x(:) =   2.00000000       5.00000000      ios=           0
> i=           3 input(i) = "2 5,"
> with decimal=point x(:) =   2.00000000       5.00000000      ios=           0
> with decimal=comma x(:) =   2.00000000       5.00000000      ios=           0
> i=           4 input(i) = "2.5,"
> with decimal=point x(:) =   2.50000000       5.00000000      ios=          -1
> End of file
> with decimal=comma x(:) =   2.50000000       666.000000      ios=        5010
> Bad real number in item 1 of list input
> i=           5 input(i) = "2,5;"
> with decimal=point x(:) =   2.00000000       5.00000000      ios=        5010
> Semicolon not allowed as separator with DECIMAL='point'
> with decimal=comma x(:) =   2.50000000       666.000000      ios=          -1
> End of file
> i=           6 input(i) = "2;5;"
> with decimal=point x(:) =   2.00000000       666.000000      ios=        5010
> Semicolon not allowed as separator with DECIMAL='point'
> with decimal=comma x(:) =   2.00000000       5.00000000      ios=           0
> i=           7 input(i) = "2 5;"
> with decimal=point x(:) =   2.00000000       5.00000000      ios=        5010
> Semicolon not allowed as separator with DECIMAL='point'
> with decimal=comma x(:) =   2.00000000       5.00000000      ios=           0
> i=           8 input(i) = "2.5;"
> with decimal=point x(:) =   2.50000000       5.00000000      ios=        5010
> Semicolon not allowed as separator with DECIMAL='point'
> with decimal=comma x(:) =   2.50000000       666.000000      ios=          -1
> End of file
> i=           9 input(i) = "2,5 "
> with decimal=point x(:) =   2.00000000       5.00000000      ios=           0
> with decimal=comma x(:) =   2.50000000       666.000000      ios=          -1
> End of file
> i=          10 input(i) = "2;5 "
> with decimal=point x(:) =   2.00000000       666.000000      ios=        5010
> Semicolon not allowed as separator with DECIMAL='point'
> with decimal=comma x(:) =   2.00000000       5.00000000      ios=           0
> i=          11 input(i) = "2 5 "
> with decimal=point x(:) =   2.00000000       5.00000000      ios=           0
> with decimal=comma x(:) =   2.00000000       5.00000000      ios=           0
> i=          12 input(i) = "2.5 "
> with decimal=point x(:) =   2.50000000       5.00000000      ios=          -1
> End of file
> with decimal=comma x(:) =   2.50000000       666.000000      ios=          -1
> End of file
> i=          13 input(i) = "2,5."
> with decimal=point x(:) =   2.00000000       5.00000000      ios=           0
> with decimal=comma x(:) =   2.00000000       666.000000      ios=        5010
> Bad real number in item 1 of list input
> i=          14 input(i) = "2;5."
> with decimal=point x(:) =   2.00000000       666.000000      ios=        5010
> Semicolon not allowed as separator with DECIMAL='point'
> with decimal=comma x(:) =   2.00000000       5.00000000      ios=           0
> i=          15 input(i) = "2 5."
> with decimal=point x(:) =   2.00000000       5.00000000      ios=           0
> with decimal=comma x(:) =   2.00000000       5.00000000      ios=           0
> i=          16 input(i) = "2.5."
> with decimal=point x(:) =   2.00000000       5.00000000      ios=        5010
> Bad real number in item 1 of list input
> with decimal=comma x(:) =   2.00000000       666.000000      ios=        5010
> Bad real number in item 1 of list input
>
> -- 
> You are receiving this mail because:
> You reported the bug.
>


-- John Harper, School of Mathematics and Statistics
Victoria Univ. of Wellington, PO Box 600, Wellington 6140, New Zealand.
e-mail john.har...@vuw.ac.nz phone +64(0) 4 463 5276

Reply via email to