User account creation filtered due to spam.

Bug 34875 - read into vector-valued section doesn't transfer any values
Summary: read into vector-valued section doesn't transfer any values
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: ---
Assignee: Paul Thomas
URL:
Keywords: wrong-code
Depends on:
Blocks: 32834
  Show dependency treegraph
 
Reported: 2008-01-19 20:40 UTC by Dick Hendrickson
Modified: 2008-01-22 22:22 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.1.3 4.2.2 4.3.0
Last reconfirmed: 2008-01-19 21:06:50


Attachments
A fix for this PR (549 bytes, patch)
2008-01-22 17:54 UTC, Paul Thomas
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dick Hendrickson 2008-01-19 20:40:32 UTC
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
Comment 1 Jerry DeLisle 2008-01-19 21:06:50 UTC
I will have a look.
Comment 2 Jerry DeLisle 2008-01-22 02:46:23 UTC
Unfamiliar with this part of front end involved.
Comment 3 Paul Thomas 2008-01-22 12:28:37 UTC
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 
Comment 4 Paul Thomas 2008-01-22 17:54:50 UTC
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
Comment 5 Paul Thomas 2008-01-22 21:22:57 UTC
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

Comment 6 Paul Thomas 2008-01-22 22:22:34 UTC
Fixed on trunk

Paul