With compiler 4.3.0 20080109 (experimental) [trunk revision 131426] (GCC) vector valued reads into an array don't appear to read in values. The test program prints out kind of qda = 4 vector valued read failed 1 -100.000000 1.00000000 2 -100.000000 2.0000000 3 -100.000000 3.0000000 4 -100.000000 4.0000000 5 -100.000000 5.0000000 6 -100.000000 6.0000000 7 -100.000000 7.0000000 8 -100.000000 8.0000000 9 -100.000000 9.0000000 10 -100.000000 10.0000000 subscript range read succeeded Dick Hendrickson Program QH0008 REAL(4) QDA(10) REAL(4) QDA1(10) integer, dimension(10) :: nfv1 = (/1,2,3,4,5,6,7,8,9,10/) qda1 = nfv1 qda = -100 print *, 'kind of qda = ', kind(qda) OPEN (UNIT=47, $ STATUS='SCRATCH', $ FORM='UNFORMATTED', $ ACTION='READWRITE') ISTAT = -314 REWIND (47, IOSTAT = ISTAT) IF ( ISTAT .NE. 0) THEN stop ' FIRST REWIND FAILED ' ENDIF ISTAT = -314 WRITE (47,IOSTAT = ISTAT) QDA1 IF ( ISTAT .NE. 0) THEN stop ' WRITE FAILED ' ENDIF ISTAT = -314 REWIND (47, IOSTAT = ISTAT) IF ( ISTAT .NE. 0) THEN stop ' SECOND REWIND FAILED ' ENDIF READ (47,IOSTAT = ISTAT) QDA(NFV1) IF ( ISTAT .NE. 0) THEN stop ' READ FAILED ' ENDIF IF ( ANY (QDA .ne. QDA1) ) then print *, 'vector valued read failed' DO I = 1,10 print *, I, qda(i), qda1(i) enddo else print *, 'vector valued read succeeded' endif ISTAT = -314 REWIND (47, IOSTAT = ISTAT) IF ( ISTAT .NE. 0) THEN stop ' THIRD REWIND FAILED ' ENDIF qda = -200 READ (47,IOSTAT = ISTAT) QDA(1:10) IF ( ISTAT .NE. 0) THEN stop ' READ FAILED ' ENDIF IF ( ANY (QDA .ne. QDA1) ) then print *, 'vector valued read failed' DO I = 1,10 print *, I, qda(i), qda1(i) enddo else print *, 'subscript range read succeeded' endif END
I will have a look.
Unfamiliar with this part of front end involved.
Dick, You seem to have an unerring aim at our.... well....weaker points. Thanks for coming in with these bugs, they are really helping. This fellow comes about because there just is no provision for writing a temporary back again in trans-io.c! If you look at the code, using -fdump-tree-original, gfortran dutifully copies in to a temporary, reads into it and then does nothing with it! Fortunately, this was something that was encountered in making function calls with "subreference arrays" (ie. pointers to the components of derived types) and the function used to solve it will work here, I think. I'll try to do it tonight. Cheers Paul
Created attachment 14998 [details] A fix for this PR As I suspected, the attached does the trick. It is regtesting right now and I want to see if I can make the test for the vector subscript a bit more elegant. It'll be submitted tomorrow morning. Paul
Subject: Bug 34875 Author: pault Date: Tue Jan 22 21:22:13 2008 New Revision: 131742 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=131742 Log: 2008-01-22 Paul Thomas <pault@gcc.gnu.org> PR fortran/34875 * trans-io.c (gfc_trans_transfer): If the array reference in a read has a vector subscript, use gfc_conv_subref_array_arg to copy back the temporary. 2008-01-22 Paul Thomas <pault@gcc.gnu.org> PR fortran/34875 * gfortran.dg/vector_subscript_3.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/vector_subscript_3.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/trans-io.c trunk/gcc/testsuite/ChangeLog
Fixed on trunk Paul