public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/34876]  New: can't read zero length array sections
@ 2008-01-19 21:39 dick dot hendrickson at gmail dot com
  2008-01-19 22:49 ` [Bug fortran/34876] " jvdelisle at gcc dot gnu dot org
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: dick dot hendrickson at gmail dot com @ 2008-01-19 21:39 UTC (permalink / raw)
  To: gcc-bugs

The following program prints READ FAILED.  A similar program
with an unformatted, rather than direct access, file also fails.

Dick Hendrickson

      Program qi0011
      CHARACTER(9) BDA(10)
      CHARACTER(9) BDA1(10)
      INTEGER  J_LEN
      ISTAT = -314

      INQUIRE(IOLENGTH = J_LEN) BDA1

      ISTAT = -314
      OPEN (UNIT=48,
     $      STATUS='SCRATCH',
     $      ACCESS='DIRECT',
     $      RECL = j_len,
     $      IOSTAT = ISTAT,
     $      FORM='UNFORMATTED',
     $      ACTION='READWRITE')


      IF (ISTAT /= 0) stop

      BDA = 'xxxxxxxxx'
      WRITE (48,IOSTAT = ISTAT, REC = 10) BDA1(4:3)
      IF ( ISTAT .NE. 0) THEN
        stop ' WRITE FAILED '
      ENDIF

      ISTAT = -314
      READ (48,IOSTAT = ISTAT, REC=10) BDA(4:3)
      IF ( ISTAT .NE. 0) THEN
        stop ' READ FAILED '
      ENDIF
      end


-- 
           Summary: can't read zero length array sections
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dick dot hendrickson at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34876


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/34876] can't read zero length array sections
  2008-01-19 21:39 [Bug fortran/34876] New: can't read zero length array sections dick dot hendrickson at gmail dot com
@ 2008-01-19 22:49 ` jvdelisle at gcc dot gnu dot org
  2008-01-20  3:49 ` jvdelisle at gcc dot gnu dot org
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2008-01-19 22:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from jvdelisle at gcc dot gnu dot org  2008-01-19 21:21 -------
I will check into this one while I am at it as well


-- 

jvdelisle at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jvdelisle at gcc dot gnu dot
                   |dot org                     |org
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2008-01-19 21:21:57
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34876


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/34876] can't read zero length array sections
  2008-01-19 21:39 [Bug fortran/34876] New: can't read zero length array sections dick dot hendrickson at gmail dot com
  2008-01-19 22:49 ` [Bug fortran/34876] " jvdelisle at gcc dot gnu dot org
@ 2008-01-20  3:49 ` jvdelisle at gcc dot gnu dot org
  2008-01-20 19:31 ` jvdelisle at gcc dot gnu dot org
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2008-01-20  3:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from jvdelisle at gcc dot gnu dot org  2008-01-20 02:56 -------
Here is a reduced case that illustrates the problem.  Not specifying the
negative stride in either the read or write results in a failure. See the
commented lines.

      program qi0011
      character(9) bda(10)
      character(9) bda1(10)
      integer  j_len
      istat = -314

      inquire(iolength = j_len) bda1

      print '("j_len=",i2)',j_len

      istat = -314
      open (unit=48,
     $      access='direct',
     $      recl = j_len,
     $      status="scratch",
     $      iostat = istat,
     $      form='unformatted',
     $      action='readwrite')

      bda = 'xxxxxxxxx'
      bda1 ='123456789'
      write (48, rec = 10) bda1(4:3:-1)! This works
c      write (48, rec = 10) bda1(4:3)              ! This fails
      read (48, rec=10) bda(7:6:-1)    ! This works
c      read (48, rec=10) bda(7:6)                  ! This fails
      print '(10(a))', bda1
      print '(10(a))', bda
      end

Looking at -fdump-tree-original:

With stride given:
    {
      struct array1_unknown parm.9;

      parm.9.dtype = 625;
      parm.9.dim[0].lbound = 1;
      parm.9.dim[0].ubound = 2;
      parm.9.dim[0].stride = -1;
      parm.9.data = (void *) (character(kind=1)[0:][1:9] *) &bda1[3];
      parm.9.offset = 0;
      _gfortran_transfer_array (&dt_parm.8, &parm.9, 1, 9);
    }

Without stride given:
    {
      struct array1_unknown parm.9;

      parm.9.dtype = 625;
      parm.9.dim[0].lbound = 1;
      parm.9.dim[0].ubound = 0;
      parm.9.dim[0].stride = 1;
      parm.9.data = (void *) (character(kind=1)[0:][1:9] *) &bda1[3];
      parm.9.offset = -4;
      _gfortran_transfer_array (&dt_parm.8, &parm.9, 1, 9);
    }


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34876


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/34876] can't read zero length array sections
  2008-01-19 21:39 [Bug fortran/34876] New: can't read zero length array sections dick dot hendrickson at gmail dot com
  2008-01-19 22:49 ` [Bug fortran/34876] " jvdelisle at gcc dot gnu dot org
  2008-01-20  3:49 ` jvdelisle at gcc dot gnu dot org
@ 2008-01-20 19:31 ` jvdelisle at gcc dot gnu dot org
  2008-01-22  3:30 ` jvdelisle at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2008-01-20 19:31 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from jvdelisle at gcc dot gnu dot org  2008-01-20 18:10 -------
In the failing case, we have no stride:

Breakpoint 1, gfc_walk_subexpr (ss=0xfc2de0, expr=0x106f6b0)
    at ../../gcc43/gcc/fortran/trans-array.c:5609
(gdb) p *expr->ref

snip
---->      stride = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, dimen_type = 

And in the passing case we do:

Breakpoint 1, gfc_walk_subexpr (ss=0xfc2de0, expr=0x106f6b0)
    at ../../gcc43/gcc/fortran/trans-array.c:5609
snip
---->      stride = {0x106fb70, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
(gdb) 


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34876


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/34876] can't read zero length array sections
  2008-01-19 21:39 [Bug fortran/34876] New: can't read zero length array sections dick dot hendrickson at gmail dot com
                   ` (2 preceding siblings ...)
  2008-01-20 19:31 ` jvdelisle at gcc dot gnu dot org
@ 2008-01-22  3:30 ` jvdelisle at gcc dot gnu dot org
  2008-01-22  6:03 ` [Bug fortran/34876] Can't read/write array sections with negative stride not specified jvdelisle at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2008-01-22  3:30 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from jvdelisle at gcc dot gnu dot org  2008-01-22 02:44 -------
Front End does set default stride to one and does not check fo rthe case of a
negative stride.  Unassigning since it is in unfamiliar territory for me.


-- 

jvdelisle at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
OtherBugsDependingO|                            |32834
              nThis|                            |
         AssignedTo|jvdelisle at gcc dot gnu dot|unassigned at gcc dot gnu
                   |org                         |dot org
             Status|ASSIGNED                    |NEW


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34876


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/34876] Can't read/write array sections with negative stride not specified
  2008-01-19 21:39 [Bug fortran/34876] New: can't read zero length array sections dick dot hendrickson at gmail dot com
                   ` (3 preceding siblings ...)
  2008-01-22  3:30 ` jvdelisle at gcc dot gnu dot org
@ 2008-01-22  6:03 ` jvdelisle at gcc dot gnu dot org
  2008-01-22  9:50 ` pault at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2008-01-22  6:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from jvdelisle at gcc dot gnu dot org  2008-01-22 05:27 -------
Changing summary to better reflect what is wrong.


-- 

jvdelisle at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|can't read zero length array|Can't read/write array
                   |sections                    |sections with negative
                   |                            |stride not specified


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34876


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/34876] Can't read/write array sections with negative stride not specified
  2008-01-19 21:39 [Bug fortran/34876] New: can't read zero length array sections dick dot hendrickson at gmail dot com
                   ` (4 preceding siblings ...)
  2008-01-22  6:03 ` [Bug fortran/34876] Can't read/write array sections with negative stride not specified jvdelisle at gcc dot gnu dot org
@ 2008-01-22  9:50 ` pault at gcc dot gnu dot org
  2008-01-22 15:17 ` jvdelisle at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: pault at gcc dot gnu dot org @ 2008-01-22  9:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pault at gcc dot gnu dot org  2008-01-22 09:03 -------
(In reply to comment #5)
> Changing summary to better reflect what is wrong.
Jerry,

Jerry,

I believe this to be something missing in the library.

Other compilers (G95 and DEC are what I can lay hands on right now), as far as
I can see, interpret the io array references as being zero length.

I think that transfer_array is, mostly, doing the right thing.  If I add
      WRITE (48,IOSTAT = ISTAT, REC = 12) BDA1(3:4)
or to any other record >10, the testcase works correctly.  Thus, rather than
just returning, with a zero length array, transfer_array has to write a zero
length record if the current record is > the number of record in the file.

I am completely lost in the library these days, whereas you are king:) Can you
have another look?

Paul


-- 

pault at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jvdelisle at gcc dot gnu dot
                   |                            |org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34876


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/34876] Can't read/write array sections with negative stride not specified
  2008-01-19 21:39 [Bug fortran/34876] New: can't read zero length array sections dick dot hendrickson at gmail dot com
                   ` (5 preceding siblings ...)
  2008-01-22  9:50 ` pault at gcc dot gnu dot org
@ 2008-01-22 15:17 ` jvdelisle at gcc dot gnu dot org
  2008-01-23  6:45 ` jvdelisle at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2008-01-22 15:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from jvdelisle at gcc dot gnu dot org  2008-01-22 14:54 -------
Yes, I will have another look.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34876


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/34876] Can't read/write array sections with negative stride not specified
  2008-01-19 21:39 [Bug fortran/34876] New: can't read zero length array sections dick dot hendrickson at gmail dot com
                   ` (6 preceding siblings ...)
  2008-01-22 15:17 ` jvdelisle at gcc dot gnu dot org
@ 2008-01-23  6:45 ` jvdelisle at gcc dot gnu dot org
  2008-01-23  7:13 ` pault at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2008-01-23  6:45 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from jvdelisle at gcc dot gnu dot org  2008-01-23 05:41 -------
I am beginning to see it now. This does not help:

      if (extent[n] <= 0)
        return;

we just bail out right now when we need to actually do something.


-- 

jvdelisle at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jvdelisle at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2008-01-19 21:21:57         |2008-01-23 05:41:31
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34876


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/34876] Can't read/write array sections with negative stride not specified
  2008-01-19 21:39 [Bug fortran/34876] New: can't read zero length array sections dick dot hendrickson at gmail dot com
                   ` (7 preceding siblings ...)
  2008-01-23  6:45 ` jvdelisle at gcc dot gnu dot org
@ 2008-01-23  7:13 ` pault at gcc dot gnu dot org
  2008-01-24  7:28 ` jvdelisle at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: pault at gcc dot gnu dot org @ 2008-01-23  7:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from pault at gcc dot gnu dot org  2008-01-23 06:45 -------
(In reply to comment #8)

> we just bail out right now when we need to actually do something.

Yes, that's what I thought.  In the circumstance where this block "exists", ie.
there is one beyond it, bailing out is OK. What does setting the block beyond
the current one do, given that it is also bailing out?  I suppose that all the
preceeding blocks are written, or the file length is set to have at least that
number of blocks?

Anyway, good luck.  I need to try to fix PR34429 asap.

Cheers

Paul


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34876


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/34876] Can't read/write array sections with negative stride not specified
  2008-01-19 21:39 [Bug fortran/34876] New: can't read zero length array sections dick dot hendrickson at gmail dot com
                   ` (8 preceding siblings ...)
  2008-01-23  7:13 ` pault at gcc dot gnu dot org
@ 2008-01-24  7:28 ` jvdelisle at gcc dot gnu dot org
  2008-01-24  8:44 ` jvdelisle at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2008-01-24  7:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from jvdelisle at gcc dot gnu dot org  2008-01-24 05:15 -------
Answering your question.  Putting the write in front of the failing one causes
seeking to that record, writing it out and flushing the buffers.  Writing
"grows" the file.  This creates "undefined" records from the beginning of the
file up to the record written.  With that the file actually has content and a
length. (Hard to read record 10 on a file with length zero)


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34876


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/34876] Can't read/write array sections with negative stride not specified
  2008-01-19 21:39 [Bug fortran/34876] New: can't read zero length array sections dick dot hendrickson at gmail dot com
                   ` (9 preceding siblings ...)
  2008-01-24  7:28 ` jvdelisle at gcc dot gnu dot org
@ 2008-01-24  8:44 ` jvdelisle at gcc dot gnu dot org
  2008-01-25 23:41 ` jvdelisle at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2008-01-24  8:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from jvdelisle at gcc dot gnu dot org  2008-01-24 07:03 -------
Created an attachment (id=15014)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15014&action=view)
Preliminary patch

This patch illustrates the fix.  What remains is to check cases of all other
I/O (formatted, sequential, stream, etc) with this situation of "zero length"
arrays


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34876


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/34876] Can't read/write array sections with negative stride not specified
  2008-01-19 21:39 [Bug fortran/34876] New: can't read zero length array sections dick dot hendrickson at gmail dot com
                   ` (10 preceding siblings ...)
  2008-01-24  8:44 ` jvdelisle at gcc dot gnu dot org
@ 2008-01-25 23:41 ` jvdelisle at gcc dot gnu dot org
  2008-01-26  0:05 ` jvdelisle at gcc dot gnu dot org
  2008-01-26  0:58 ` jvdelisle at gcc dot gnu dot org
  13 siblings, 0 replies; 15+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2008-01-25 23:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from jvdelisle at gcc dot gnu dot org  2008-01-25 23:35 -------
Subject: Bug 34876

Author: jvdelisle
Date: Fri Jan 25 23:34:53 2008
New Revision: 131848

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=131848
Log:
2008-01-25  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

        PR libfortran/34876
        * io/transfer.c (write_buf): Handle case of zero sized array.
        (transfer_array): Set data pointer to NULL and size to zero.  Then
        make a data transfer and return.

Modified:
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/io/transfer.c


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34876


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/34876] Can't read/write array sections with negative stride not specified
  2008-01-19 21:39 [Bug fortran/34876] New: can't read zero length array sections dick dot hendrickson at gmail dot com
                   ` (11 preceding siblings ...)
  2008-01-25 23:41 ` jvdelisle at gcc dot gnu dot org
@ 2008-01-26  0:05 ` jvdelisle at gcc dot gnu dot org
  2008-01-26  0:58 ` jvdelisle at gcc dot gnu dot org
  13 siblings, 0 replies; 15+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2008-01-26  0:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #13 from jvdelisle at gcc dot gnu dot org  2008-01-25 23:41 -------
Subject: Bug 34876

Author: jvdelisle
Date: Fri Jan 25 23:40:23 2008
New Revision: 131850

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=131850
Log:
2008-01-25  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

        PR libfortran/34876
        * gfortran.dg/direct_io_9.f: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/direct_io_9.f
Modified:
    trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34876


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug fortran/34876] Can't read/write array sections with negative stride not specified
  2008-01-19 21:39 [Bug fortran/34876] New: can't read zero length array sections dick dot hendrickson at gmail dot com
                   ` (12 preceding siblings ...)
  2008-01-26  0:05 ` jvdelisle at gcc dot gnu dot org
@ 2008-01-26  0:58 ` jvdelisle at gcc dot gnu dot org
  13 siblings, 0 replies; 15+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2008-01-26  0:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #14 from jvdelisle at gcc dot gnu dot org  2008-01-26 00:04 -------
Fixed on trunk. Thanks for bug report and test case.


-- 

jvdelisle at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34876


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2008-01-26  0:05 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-19 21:39 [Bug fortran/34876] New: can't read zero length array sections dick dot hendrickson at gmail dot com
2008-01-19 22:49 ` [Bug fortran/34876] " jvdelisle at gcc dot gnu dot org
2008-01-20  3:49 ` jvdelisle at gcc dot gnu dot org
2008-01-20 19:31 ` jvdelisle at gcc dot gnu dot org
2008-01-22  3:30 ` jvdelisle at gcc dot gnu dot org
2008-01-22  6:03 ` [Bug fortran/34876] Can't read/write array sections with negative stride not specified jvdelisle at gcc dot gnu dot org
2008-01-22  9:50 ` pault at gcc dot gnu dot org
2008-01-22 15:17 ` jvdelisle at gcc dot gnu dot org
2008-01-23  6:45 ` jvdelisle at gcc dot gnu dot org
2008-01-23  7:13 ` pault at gcc dot gnu dot org
2008-01-24  7:28 ` jvdelisle at gcc dot gnu dot org
2008-01-24  8:44 ` jvdelisle at gcc dot gnu dot org
2008-01-25 23:41 ` jvdelisle at gcc dot gnu dot org
2008-01-26  0:05 ` jvdelisle at gcc dot gnu dot org
2008-01-26  0:58 ` jvdelisle at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).