[Bug fortran/105473] semicolon allowed when list-directed read integer with decimal='point'
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105473 --- Comment #25 from harper at msor dot vuw.ac.nz --- I received your patch but I have no idea how to install it - I have been using Fortran off and on since 1963 but I am not a systems programmer. My version of gfortran is gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1) On Sat, 2 Jul 2022, jvdelisle at gcc dot gnu.org wrote: > Date: Sat, 2 Jul 2022 17:14:05 + > From: jvdelisle at gcc dot gnu.org > To: John Harper > Subject: [Bug fortran/105473] semicolon allowed when list-directed read > integer with decimal='point' > Resent-Date: Sun, 3 Jul 2022 05:14:17 +1200 (NZST) > Resent-From: > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105473 > > Jerry DeLisle changed: > > What|Removed |Added > > Attachment #52981|0 |1 >is obsolete|| > > --- Comment #24 from Jerry DeLisle --- > Created attachment 53241 > --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53241&action=edit > Revised patch that may be as good as it gets. > > I have not had time to commit this, but this would be it. If you can test it > and point out any issues it is appreciated. > > -- > 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
[Bug fortran/105473] semicolon allowed when list-directed read integer with decimal='point'
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105473 --- Comment #23 from harper at msor dot vuw.ac.nz --- Given what "undefined" means in Fortran, I see no bug now. On Fri, 3 Jun 2022, jvdelisle at gcc dot gnu.org wrote: > Date: Fri, 3 Jun 2022 21:04:22 + > From: jvdelisle at gcc dot gnu.org > To: John Harper > Subject: [Bug fortran/105473] semicolon allowed when list-directed read > integer with decimal='point' > Resent-Date: Sat, 4 Jun 2022 09:04:35 +1200 (NZST) > Resent-From: > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105473 > > --- Comment #22 from Jerry DeLisle --- > 12.11.2 (6) says "if the statement is a READ statement or the error > condition occurs in a wait operation for a transfer initiated by a READ > statement, all input items or namelist group objects in the statement that > initiated the transfer become undefined;" > > By undefined, it means you cant rely on it whether or not it has a value read > into it or not. It is undefined by the standard and to the user, so it could > be anything, > > There was one last place I am going to check in the code before I am done. > (maybe ;)) > > Regarding NAG, yes we always use to like to see that interpretation. > > -- > 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
[Bug fortran/105473] semicolon allowed when list-directed read integer with decimal='point'
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105473 --- Comment #21 from harper at msor dot vuw.ac.nz --- I have only one problem here, and it's with the f2018 standard seeming to contradict itself in two places that both apply to this program. 12.11.1 begins "The set of input/output error conditions is processor dependent. Except as otherwise specified, when an error condition occurs or is detected is processor dependent." 12.11.2 (6) says "if the statement is a READ statement or the error condition occurs in a wait operation for a transfer initiated by a READ statement, all input items or namelist group objects in the statement that initiated the transfer become undefined;" In the 3rd case below, the output i== 2 input="2;5," with point x = 2.0 999.0 ERR seems to me OK by 12.11.1 (error condition occurring after reading x(1) as 2.0) but 12.11.2 seems to imply that neither x(1) nor x(2) should be read, making the output i= 2 input="2;5," with point x = 666.0 999.0 ERR That is what ifort did with the program, but if the standard is ambiguous I can't complain if gfortran and ifort interpret it differently. There is of course also the cop-out that if the program is not standard-compliant then compilers can do what they like with it. The other cases where gfortran and ifort disagreed are listed below. They all involve point and ERR. I give the gfortran result first then the ifort result. i= 5 input="2,5;" with point x =2.05.0 ERR i= 5 input="2,5;" with point x =2.0 999.0 ERR i= 6 input="2;5;" with point x =2.0 999.0 ERR i= 6 input="2;5;" with point x = 666.0 999.0 ERR i= 7 input="2 5;" with point x =2.05.0 ERR i= 7 input="2 5;" with point x =2.0 999.0 ERR i= 8 input="2.5;" with point x =2.5 999.0 ERR i= 8 input="2.5;" with point x = 666.0 999.0 ERR i=10 input="2;5 " with point x =2.0 999.0 ERR i=10 input="2;5 " with point x = 666.0 999.0 ERR i=14 input="2;5." with point x =2.0 999.0 ERR i=14 input="2;5." with point x = 666.0 999.0 ERR Oddly, there was one point and ERR case where gfortran agreed with ifort: i=16 input="2.5." with point x = 666.0 999.0 ERR I wish I still had access to the NAG compiler! > Date: Fri, 3 Jun 2022 04:33:33 + > From: jvdelisle at gcc dot gnu.org > To: John Harper > Subject: [Bug fortran/105473] semicolon allowed when list-directed read > integer with decimal='point' > Resent-Date: Fri, 3 Jun 2022 16:33:45 +1200 (NZST) > Resent-From: > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105473 > > --- Comment #20 from Jerry DeLisle --- > Please check this. Second pair of eyes needed. > > $ ./a.out > i= 1 input="2,5," with point x =2.05.0 OK > i= 1 input="2,5," with comma x = 666.0 999.0 ERR > > i= 2 input="2;5," with point x =2.0 999.0 ERR > i= 2 input="2;5," with comma x =2.05.0 OK > > i= 3 input="2 5," with point x =2.05.0 OK > i= 3 input="2 5," with comma x =2.05.0 OK > > i= 4 input="2.5," with point x =2.5 999.0 end > i= 4 input="2.5," with comma x = 666.0 999.0 ERR > > i= 5 input="2,5;" with point x =2.05.0 ERR > i= 5 input="2,5;" with comma x =2.5 999.0 end > > i= 6 input="2;5;" with point x =2.0 999.0 ERR > i= 6 input="2;5;" with comma x =2.05.0 OK > > i= 7 input="2 5;" with point x =2.05.0 ERR > i= 7 input="2 5;" with comma x =2.05.0 OK > > i= 8 input="2.5;" with point x =2.5 999.0 ERR > i= 8 input="2.5;" with comma x = 666.0 999.0 ERR > > i= 9 input="2,5 " with point x =2.05.0 OK > i= 9 input="2,5 " with comma x =2.5 999.0 end > > i=10 input="2;5 " with point x =2.0 999.0 ERR > i=10 input="2;5 " with comma x =2.05.0 OK > > i=11 input="2 5 " with point x =2.05.0 OK > i=11 input="2 5 " with comma x =2.05.0 OK > > i=12 input="2.5 " with point x =2.5 999.0 end > i=12 input="2.5 " with comma x = 666.0 999.0 ERR > > i=13 input="2,5." with point x =2.05.0 OK > i=13 input="2,5." with comma x = 666.0 999.0 ERR > > i=14 input="2;5." with point x =2.0 999.0 ERR > i=14 input="2;5." with comma x =2.0 999.0 ERR > > i=15 input="2 5." with point x =2.05.0 OK > i=15 input="2 5." with comma x =2.0 999.0 ERR > > i=16 input="2.5." with point x = 666.0 999.0 ERR > i=16 input="2.5." with comma x = 666.0 999.0 ERR > > -- > 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
[Bug fortran/105473] semicolon allowed when list-directed read integer with decimal='point'
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105473 --- Comment #19 from harper at msor dot vuw.ac.nz --- Thank you. To make the outputs from my test program testdecimal.f90 easier to compare when using different compilers, and to clarify where a reading error happened, I have revised the program to make its results clearer. Below is the new version of the program. I see no point in sending its output with my gfortran, which does not have Jerry's latest corrections, but I do provide its output with ifort, which it is not your job to debug! john@johns-laptop:~/Jfh$ cat testdecimal.f90 ! Test list-directed reading with decimal='point' and 'comma' by ! printing one line for each of 32 cases, reading input(1:16) with each ! of 'point' or 'comma', using s(ios) to give ERR, OK or end according ! to the iostat=ios value from reading. Before reading, x=[666,999]. implicit none real x(2) integer ios,i,j character(*),parameter:: punc=",; .",fmt='(1X,A,I2,1X,5A,2F7.1,1X,A)' integer,parameter:: lpunc =len(punc) character:: dec(2)*5=['point','comma'], input(lpunc**2)*4 = & [(("2"//punc(i:i)//"5"//punc(j:j),i=1,lpunc),j=1,lpunc)] do i = 1,size(input) do j = 1,2 x = [666, 999] read(input(i),*,decimal=dec(j),iostat=ios) x print fmt,'i=',i,' input="',input(i),'" with ',dec(j),& ' x =',x,s(ios) end do end do contains character(3) function s(ios) ! ERR, OK ,end if ios>0, ==0, <0 integer,intent(in):: ios s = merge('ERR',merge(' OK','end',ios==0),ios>0) end function s end program john@johns-laptop:~/Jfh$ ifort testdecimal.f90; ./a.out Compiling "ifort testdecimal.f90" i= 1 input="2,5," with point x =2.05.0 OK i= 1 input="2,5," with comma x = 666.0 999.0 ERR i= 2 input="2;5," with point x = 666.0 999.0 ERR i= 2 input="2;5," with comma x =2.05.0 OK i= 3 input="2 5," with point x =2.05.0 OK i= 3 input="2 5," with comma x =2.05.0 OK i= 4 input="2.5," with point x =2.5 999.0 end i= 4 input="2.5," with comma x = 666.0 999.0 ERR i= 5 input="2,5;" with point x =2.0 999.0 ERR i= 5 input="2,5;" with comma x =2.5 999.0 end i= 6 input="2;5;" with point x = 666.0 999.0 ERR i= 6 input="2;5;" with comma x =2.05.0 OK i= 7 input="2 5;" with point x =2.0 999.0 ERR i= 7 input="2 5;" with comma x =2.05.0 OK i= 8 input="2.5;" with point x = 666.0 999.0 ERR i= 8 input="2.5;" with comma x = 666.0 999.0 ERR i= 9 input="2,5 " with point x =2.05.0 OK i= 9 input="2,5 " with comma x =2.5 999.0 end i=10 input="2;5 " with point x = 666.0 999.0 ERR i=10 input="2;5 " with comma x =2.05.0 OK i=11 input="2 5 " with point x =2.05.0 OK i=11 input="2 5 " with comma x =2.05.0 OK i=12 input="2.5 " with point x =2.5 999.0 end i=12 input="2.5 " with comma x = 666.0 999.0 ERR i=13 input="2,5." with point x =2.05.0 OK i=13 input="2,5." with comma x = 666.0 999.0 ERR i=14 input="2;5." with point x = 666.0 999.0 ERR i=14 input="2;5." with comma x =2.0 999.0 ERR i=15 input="2 5." with point x =2.05.0 OK i=15 input="2 5." with comma x =2.0 999.0 ERR i=16 input="2.5." with point x = 666.0 999.0 ERR i=16 input="2.5." with comma x = 666.0 999.0 ERR john@johns-laptop:~/Jfh$ On Wed, 18 May 2022, jvdelisle at gcc dot gnu.org wrote: > Date: Wed, 18 May 2022 02:52:26 + > From: jvdelisle at gcc dot gnu.org > To: John Harper > Subject: [Bug fortran/105473] semicolon allowed when list-directed read > integer with decimal='point' > Resent-Date: Wed, 18 May 2022 14:52:38 +1200 (NZST) > Resent-From: > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105473 > > --- Comment #18 from Jerry DeLisle --- > (In reply to harper from comment #17) >> On comparing that with ifort's result I think that the only remaining bug >> is that if decimal='comma' then '.' is neither a decimal symbol nor a >> separator (see f2018 13.6). > > Making this easier for others to see. > > With gfortran I see with the 8th sub-case: > > i= 8 input(i) = "2.5;" > with decimal=point x(:) =2.5 666.0 ios=5010 > with decimal=comma x(:) =2.5 666.0 ios=-1 > > i= 12 input(i) = "2.5 " > with decimal=point x(:) =2.5 666.0 ios=-1 > with decimal=comma x(:) =2.5 666.0 ios=-1 > > In these cases the decimal=comma should have never seen 2.5 > > With ifort: > > i= 8 input(i) = "2.5;" > with decimal=point x(:) = 2.5000 5. ios=5010 > with decimal=comma x(:) = 2.5000 666.00 ios= -1 > > I don't think ifort has the decimal=point part right, as if it backed up and > read the digit 5 a second time. > > Regardless, getting closer here. I will work on the gfortran comma issue. > > -- > You are receiving this mail because: > You reported the bug. > -- John Harper
[Bug fortran/105473] semicolon allowed when list-directed read integer with decimal='point'
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105473 --- Comment #17 from harper at msor dot vuw.ac.nz --- On comparing that with ifort's result I think that the only remaining bug is that if decimal='comma' then '.' is neither a decimal symbol nor a separator (see f2018 13.6). On Mon, 16 May 2022, jvdelisle at gcc dot gnu.org wrote: > Date: Mon, 16 May 2022 00:49:44 + > From: jvdelisle at gcc dot gnu.org > To: John Harper > 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: > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105473 > > --- Comment #13 from Jerry DeLisle --- > 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. 5. ios= 0 > with decimal=comma x(:) = 2. 666.00 ios=5010 > i= 2 input(i) = "2;5," > with decimal=point x(:) = 2. 666.00 ios=5010 > with decimal=comma x(:) = 2. 5. ios= 0 > i= 3 input(i) = "2 5," > with decimal=point x(:) = 2. 5. ios= 0 > with decimal=comma x(:) = 2. 5. ios= 0 > i= 4 input(i) = "2.5," > with decimal=point x(:) = 2.5000 5. ios= -1 > with decimal=comma x(:) = 2.5000 666.00 ios=5010 > i= 5 input(i) = "2,5;" > with decimal=point x(:) = 2. 5. ios=5010 > with decimal=comma x(:) = 2.5000 666.00 ios= -1 > i= 6 input(i) = "2;5;" > with decimal=point x(:) = 2. 666.00 ios=5010 > with decimal=comma x(:) = 2. 5. ios= 0 > i= 7 input(i) = "2 5;" > with decimal=point x(:) = 2. 5. ios=5010 > with decimal=comma x(:) = 2. 5. ios= 0 > i= 8 input(i) = "2.5;" > with decimal=point x(:) = 2.5000 5. ios=5010 > with decimal=comma x(:) = 2.5000 666.00 ios= -1 > i= 9 input(i) = "2,5 " > with decimal=point x(:) = 2. 5. ios= 0 > with decimal=comma x(:) = 2.5000 666.00 ios= -1 > i= 10 input(i) = "2;5 " > with decimal=point x(:) = 2. 666.00 ios=5010 > with decimal=comma x(:) = 2. 5. ios= 0 > i= 11 input(i) = "2 5 " > with decimal=point x(:) = 2. 5. ios= 0 > with decimal=comma x(:) = 2. 5. ios= 0 > i= 12 input(i) = "2.5 " > with decimal=point x(:) = 2.5000 5. ios= -1 > with decimal=comma x(:) = 2.5000 666.00 ios= -1 > i= 13 input(i) = "2,5." > with decimal=point x(:) = 2. 5. ios= 0 > with decimal=comma x(:) = 2. 666.00 ios=5010 > i= 14 input(i) = "2;5." > with decimal=point x(:) = 2. 666.00 ios=5010 > with decimal=comma x(:) = 2. 5. ios= 0 > i= 15 input(i) = "2 5." > with decimal=point x(:) = 2. 5. ios= 0 > with decimal=comma x(:) = 2. 5. ios= 0 > i= 16 input(i) = "2.5." > with decimal=point x(:) = 2. 5. ios=5010 > with decimal=comma x(:) = 2. 666.00 ios=5010 > [jerry@amdr pr105473]$ gfc multi.f90 > [jerry@amdr pr105473]$ ./a.out > i= 1 input(i) = "2,5," > with decimal=point x(:) = 2. 5. ios= 0 > with decimal=comma x(:) = 2. 666.00 ios=5010 > Bad real number in item 1 of list input > i= 2 input(i) = "2;5," > with decimal=point x(:) = 2. 666.00 ios=5010 > Semicolon not allowed as separator with DECIMAL='point' > with decimal=comma x(:) = 2. 5. ios= 0 > i= 3 input(i) = "2 5," > with decimal=point x(:) = 2. 5. ios= 0 > with decimal=comma x(:) = 2. 5. ios= 0 > i= 4 input(i) = "2.5," > with decimal=point x(:) = 2.5000 5. ios= -1 > End of file > with decimal=comma x(:) = 2.5000 666.
[Bug fortran/105473] semicolon allowed when list-directed read integer with decimal='point'
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105473 --- Comment #16 from harper at msor dot vuw.ac.nz --- I have now used ifort on my latest test program, which you should already have, in the hope that it helps you. It printed this: john@johns-laptop:~/Jfh$ ifort testiostat4.f90 Compiling "ifort testiostat4.f90" john@johns-laptop:~/Jfh$ ./a.out i= 1 input(i) = "2,5," with decimal=point x(:) = 2.0 5.0 ios=0 with decimal=comma x(:) = 666.0 666.0 ios=59 i= 2 input(i) = "2;5," with decimal=point x(:) = 666.0 666.0 ios=59 with decimal=comma x(:) = 2.0 5.0 ios=0 i= 3 input(i) = "2 5," with decimal=point x(:) = 2.0 5.0 ios=0 with decimal=comma x(:) = 2.0 5.0 ios=0 i= 4 input(i) = "2.5," with decimal=point x(:) = 2.5 666.0 ios=-1 with decimal=comma x(:) = 666.0 666.0 ios=59 i= 5 input(i) = "2,5;" with decimal=point x(:) = 2.0 666.0 ios=59 with decimal=comma x(:) = 2.5 666.0 ios=-1 i= 6 input(i) = "2;5;" with decimal=point x(:) = 666.0 666.0 ios=59 with decimal=comma x(:) = 2.0 5.0 ios=0 i= 7 input(i) = "2 5;" with decimal=point x(:) = 2.0 666.0 ios=59 with decimal=comma x(:) = 2.0 5.0 ios=0 i= 8 input(i) = "2.5;" with decimal=point x(:) = 666.0 666.0 ios=59 with decimal=comma x(:) = 666.0 666.0 ios=59 i= 9 input(i) = "2,5 " with decimal=point x(:) = 2.0 5.0 ios=0 with decimal=comma x(:) = 2.5 666.0 ios=-1 i= 10 input(i) = "2;5 " with decimal=point x(:) = 666.0 666.0 ios=59 with decimal=comma x(:) = 2.0 5.0 ios=0 i= 11 input(i) = "2 5 " with decimal=point x(:) = 2.0 5.0 ios=0 with decimal=comma x(:) = 2.0 5.0 ios=0 i= 12 input(i) = "2.5 " with decimal=point x(:) = 2.5 666.0 ios=-1 with decimal=comma x(:) = 666.0 666.0 ios=59 i= 13 input(i) = "2,5." with decimal=point x(:) = 2.0 5.0 ios=0 with decimal=comma x(:) = 666.0 666.0 ios=59 i= 14 input(i) = "2;5." with decimal=point x(:) = 666.0 666.0 ios=59 with decimal=comma x(:) = 2.0 666.0 ios=59 i= 15 input(i) = "2 5." with decimal=point x(:) = 2.0 5.0 ios=0 with decimal=comma x(:) = 2.0 666.0 ios=59 i= 16 input(i) = "2.5." with decimal=point x(:) = 666.0 666.0 ios=59 with decimal=comma x(:) = 666.0 666.0 ios=59 john@johns-laptop:~/Jfh$ -- 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 -- Forwarded message -- Date: Mon, 16 May 2022 01:44:15 + From: harper at msor dot vuw.ac.nz To: John Harper Subject: [Bug fortran/105473] semicolon allowed when list-directed read integer with decimal='point' Resent-Date: Mon, 16 May 2022 13:44:25 +1200 (NZST) Resent-From: 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 + > From: jvdelisle at gcc dot gnu.org > To: John Harper > 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: > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105473 > > --- Comment #13 from Jerry DeLisle --- > 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. 5. ios= 0 > with decimal=comma x(:) = 2. 666.00 ios=5010 > i= 2 input(i) = "2;5," >
[Bug fortran/105473] semicolon allowed when list-directed read integer with decimal='point'
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 + > From: jvdelisle at gcc dot gnu.org > To: John Harper > 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: > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105473 > > --- Comment #13 from Jerry DeLisle --- > 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. 5. ios= 0 > with decimal=comma x(:) = 2. 666.00 ios=5010 > i= 2 input(i) = "2;5," > with decimal=point x(:) = 2. 666.00 ios=5010 > with decimal=comma x(:) = 2. 5. ios= 0 > i= 3 input(i) = "2 5," > with decimal=point x(:) = 2. 5. ios= 0 > with decimal=comma x(:) = 2. 5. ios= 0 > i= 4 input(i) = "2.5," > with decimal=point x(:) = 2.5000 5. ios= -1 > with decimal=comma x(:) = 2.5000 666.00 ios=5010 > i= 5 input(i) = "2,5;" > with decimal=point x(:) = 2. 5. ios=5010 > with decimal=comma x(:) = 2.5000 666.00 ios= -1 > i= 6 input(i) = "2;5;" > with decimal=point x(:) = 2. 666.00 ios=5010 > with decimal=comma x(:) = 2. 5. ios= 0 > i= 7 input(i) = "2 5;" > with decimal=point x(:) = 2. 5. ios=5010 > with decimal=comma x(:) = 2. 5. ios= 0 > i= 8 input(i) = "2.5;" > with decimal=point x(:) = 2.5000 5. ios=5010 > with decimal=comma x(:) = 2.5000 666.00 ios= -1 > i= 9 input(i) = "2,5 " > with decimal=point x(:) = 2. 5. ios= 0 > with decimal=comma x(:) = 2.5000 666.00 ios= -1 > i= 10 input(i) = "2;5 " > with decimal=point x(:) = 2. 666.00 ios=5010 > with decimal=comma x(:) = 2. 5. ios= 0 > i= 11 input(i) = "2 5 " > with decimal=point x(:) = 2. 5. ios= 0 > with decimal=comma x(:) = 2. 5. ios= 0 > i= 12 input(i) = "2.5 " > with decimal=point x(:) = 2.5000 5. ios= -1 > with decimal=comma x(:) = 2.5000 666.00 ios= -1 > i= 13 input(i) = "2,5." > with decimal=point x(:) = 2. 5. ios= 0 > with decimal=comma x(:) = 2. 666.00 ios=5010 > i= 14 input(i) = "2;5." > with decimal=point x(:) = 2. 666.00 ios=5010 > with decimal=comma x(:) = 2. 5. ios= 0 > i= 15 input(i) = "2 5." > with decimal=point x(:) = 2. 5. ios= 0 > with decimal=comma x(:) = 2. 5. ios= 0 > i= 16 input(i) = "2.5." > with decimal=point x(:) = 2. 5. ios=5010 > with decimal=comma x(:) = 2. 666
[Bug fortran/105473] semicolon allowed when list-directed read integer with decimal='point'
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105473 --- Comment #11 from harper at msor dot vuw.ac.nz --- Thank you Jerry. Commas as separators with DECIMAL = 'comma' may be trickier because commas then do the job that decimal points normally do, and they cannot act as separators. Here is a little test program that reads from all 16 of "2p5q" where p and q are comma,semicolon,blank, or point, using both 'comma' and 'point'. It gave me the same 60 lines of output with -std=f2003 or -std=f2018 ! Does list-directed reading work properly with decimal='comma' ? implicit none real x(2) character(*),parameter:: punc = ",; ." 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),'"' read(input(i),*,decimal='point',iostat=ios,iomsg=msg) x print *,'with decimal=point x(:) =',x,' ios=',ios if(ios/=0) print *,trim(msg) x(2) = 666 read(input(i),*,decimal='comma',iostat=ios,iomsg=msg) x print *,'with decimal=comma x(:) =',x,' ios=',ios if(ios/=0) print *,trim(msg) end do end program On Sun, 15 May 2022, jvdelisle at gcc dot gnu.org wrote: > Date: Sun, 15 May 2022 15:56:00 + > From: jvdelisle at gcc dot gnu.org > To: John Harper > Subject: [Bug fortran/105473] semicolon allowed when list-directed read > integer with decimal='point' > Resent-Date: Mon, 16 May 2022 03:56:12 +1200 (NZST) > Resent-From: > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105473 > > --- Comment #10 from Jerry DeLisle --- > Just completed good regression testing and have this: > > testinput = "1;17;3.14159" > At line 8 of file pr105473.f90 > Fortran runtime error: Semicolon not allowed as separator with DECIMAL='point' > > Now I wonder if I should likewise do the same for the other case with > DECIMAL='comma' and we find a 'comma' separator. > > -- > 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
[Bug fortran/105473] semicolon allowed when list-directed read integer with decimal='point'
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105473 --- Comment #8 from harper at msor dot vuw.ac.nz --- Thank you. Unfortunately I think you found some but not all of what the standard says about semicolons as separators. You will recall that my original bug report had a program compiled with std=f2003, which should disallow extensions to that standard. (I chose f2003 because that was the first version in which POINT and COMMA appeared.) I admit that the f2003 standard 10.9 begins as follows: List-directed input/output allows data editing according to the type of the list item instead of by a format specification. It also allows data to be free-field, that is, separated by commas (or semicolons) or blanks. That would allow a free choice between comma and semicolon, except that later in 10.9 a semicolon is allowed only if the decimal edit mode is COMMA. In my test program the decimal edit mode was POINT, not COMMA. The wording that may have been overlooked was this: A value separator is (1) A comma optionally preceded by one or more contiguous blanks and optionally followed by one or more contiguous blanks, unless the decimal edit mode is COMMA, in which case a semicolon is used in place of the comma, (2) ... Equivalent wording to f2003 10.9 is in f2018 13.10.1 and 13.10.2. On Sat, 14 May 2022, jvdelisle at gcc dot gnu.org wrote: > Date: Sat, 14 May 2022 22:00:09 + > From: jvdelisle at gcc dot gnu.org > To: John Harper > Subject: [Bug fortran/105473] semicolon allowed when list-directed read > integer with decimal='point' > Resent-Date: Sun, 15 May 2022 10:00:21 +1200 (NZST) > Resent-From: > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105473 > > --- Comment #7 from Jerry DeLisle --- > My apologies for taking some time to get back to this. After a closer look, I > realize that in the original test case there is no problem. The semicolon is > an acceptable value separator regardless of decimal='point' or decimal='comma' > > Take these two examples: > > 1) The comma is the decimal keeper so semicolon must be used as the separator > > implicit none > integer n,m,ios > real r > character(20):: testinput = '1;17;3,14159' > n = 999 > print *,'testinput = "',testinput,'"' > read(testinput,*,decimal='comma', iostat=ios) n, m, r > print *,'n=',n,' m= ', m,' r= ', r,' ios=',ios > if(ios>0) print *,'testinput was not an integer' > end program > > 2) The point is the decimal keeper so semicolon may be used as the separator > or > a comma > > implicit none > integer n,m,ios > real r > character(20):: testinput = '1;17;3.14159' > n = 999 > print *,'testinput = "',testinput,'"' > read(testinput,*,decimal='point', iostat=ios) n, m, r > print *,'n=',n,' m= ', m,' r= ', r,' ios=',ios > if(ios>0) print *,'testinput was not an integer' > end program > > In the original test case, the semicolon is a separator and is simply ending > the read as no value is there. > > -- > 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
[Bug fortran/105473] semicolon allowed when list-directed read integer with decimal='point'
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105473 --- Comment #3 from harper at msor dot vuw.ac.nz --- Thank you. Of course the program did not compile with -std=f95 because there was no decimal='point' option then. But with -std=f2003 or f2008 or f2018, and with or without n = 999 before the read statement, ios was always 0 after it. I had thought that extensions to the relevant standard were supposed to be disallowed when one compiled with a std= version. Ifort gave a positive value of ios, which the f2003, f2008 and f2018 standards all require for that program. On Thu, 5 May 2022, jvdelisle2 at gmail dot com wrote: > Date: Thu, 5 May 2022 02:14:42 + > From: jvdelisle2 at gmail dot com > To: John Harper > Subject: [Bug fortran/105473] semicolon allowed when list-directed read > integer with decimal='point' > Resent-Date: Thu, 5 May 2022 14:14:52 +1200 (NZST) > Resent-From: > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105473 > > Jerry DeLisle changed: > > What|Removed |Added > > CC||jvdelisle2 at gmail dot com > > --- Comment #1 from Jerry DeLisle --- > Well, looks like we are allowing as an extension. > > $ gfortran -std=f95 pr105473.f90 > pr105473.f90:6:27: > >6 | read(testinput,*,decimal='point',iostat=ios) n > | 1 > Error: Fortran 2003: DECIMAL= at (1) not allowed in Fortran 95 > > If you set n to some value so that it is 'defined' per the standards like > this: > > ! Does list-directed reading an integer allow some non-integer input? > implicit none > integer n,ios > character(1):: testinput = ';' > n = 999 > print *,'testinput = "',testinput,'"' > read(testinput,*,decimal='point',iostat=ios) n > print *,'n=',n,' ios=',ios > if(ios>0) print *,'testinput was not an integer' > end program > > $ gfortran pr105473.f90 > [jerry@amdr pr105473]$ ./a.out > testinput = ";" > n= 999 ios= 0 > > You will see that nothing is read into n at all. The list read is just ended. > > -- > 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