mirror of git://gcc.gnu.org/git/gcc.git
re PR libfortran/16908 (Segfault in libgfortran/io/transfer.c)
2004-08-21 Bud Davis <bdavis9659@comcast.net> PR 16908 * io/transfer.c (next_record_w): Do not blank pad. * io/transfer.c (next_record): Take into account partial records. testsuite/ * gfortran.dg/direct_io.f90: New test. From-SVN: r86361
This commit is contained in:
parent
be2043db43
commit
0fa1b65cad
|
@ -1,3 +1,8 @@
|
||||||
|
2004-08-21 Bud Davis <bdavis9659@comcast.net>
|
||||||
|
|
||||||
|
PR 16908
|
||||||
|
* gfortran.dg/direct_io.f90: New test.
|
||||||
|
|
||||||
2004-08-20 Mark Mitchell <mark@codesourcery.com>
|
2004-08-20 Mark Mitchell <mark@codesourcery.com>
|
||||||
|
|
||||||
PR c++/17121
|
PR c++/17121
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
! PR 16908
|
||||||
|
! Segfaulted on second set of writes. We weren't handling partial records
|
||||||
|
! properly when calculating the file position.
|
||||||
|
program direct_io_1
|
||||||
|
implicit none
|
||||||
|
|
||||||
|
integer n, nt, mt, m
|
||||||
|
real dt, tm, w
|
||||||
|
real, allocatable :: p(:)
|
||||||
|
|
||||||
|
nt = 2049 ! if nt < 2049, then everything works.
|
||||||
|
|
||||||
|
allocate(p(nt))
|
||||||
|
p = 0.e0
|
||||||
|
|
||||||
|
inquire(iolength=mt) (p(m), m=1, nt)
|
||||||
|
|
||||||
|
open(unit=12, file='syn.sax', access='direct', recl=mt)
|
||||||
|
n = 1
|
||||||
|
write(12, rec=n) mt, nt
|
||||||
|
write(12, rec=n+1) (p(m), m=1, nt)
|
||||||
|
close(12)
|
||||||
|
|
||||||
|
inquire(iolength=mt) (p(m), m=1, nt)
|
||||||
|
|
||||||
|
open(unit=12, file='syn.sax', access='direct', recl=mt)
|
||||||
|
n = 1
|
||||||
|
write(12, rec=n) mt, nt
|
||||||
|
write(12, rec=n+1) (p(m), m=1, nt)
|
||||||
|
close(12)
|
||||||
|
end program
|
|
@ -1,3 +1,9 @@
|
||||||
|
2004-08-21 Bud Davis <bdavis9659@comcast.net>
|
||||||
|
|
||||||
|
PR 16908
|
||||||
|
* io/transfer.c (next_record_w): Do not blank pad.
|
||||||
|
* io/transfer.c (next_record): Take into account partial records.
|
||||||
|
|
||||||
2004-08-18 Victor Leikehman <lei@il.ibm.com>
|
2004-08-18 Victor Leikehman <lei@il.ibm.com>
|
||||||
|
|
||||||
PR fortran/13278
|
PR fortran/13278
|
||||||
|
|
|
@ -1223,20 +1223,23 @@ next_record_w (int done)
|
||||||
switch (current_mode ())
|
switch (current_mode ())
|
||||||
{
|
{
|
||||||
case FORMATTED_DIRECT:
|
case FORMATTED_DIRECT:
|
||||||
case UNFORMATTED_DIRECT:
|
|
||||||
if (current_unit->bytes_left == 0)
|
if (current_unit->bytes_left == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
length = current_unit->bytes_left;
|
length = current_unit->bytes_left;
|
||||||
|
|
||||||
p = salloc_w (current_unit->s, &length);
|
p = salloc_w (current_unit->s, &length);
|
||||||
|
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
goto io_error;
|
goto io_error;
|
||||||
|
|
||||||
memset (p, ' ', current_unit->bytes_left);
|
memset (p, ' ', current_unit->bytes_left);
|
||||||
if (sfree (current_unit->s) == FAILURE)
|
if (sfree (current_unit->s) == FAILURE)
|
||||||
goto io_error;
|
goto io_error;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case UNFORMATTED_DIRECT:
|
||||||
|
if (sfree (current_unit->s) == FAILURE)
|
||||||
|
goto io_error;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UNFORMATTED_SEQUENTIAL:
|
case UNFORMATTED_SEQUENTIAL:
|
||||||
|
@ -1304,6 +1307,7 @@ next_record_w (int done)
|
||||||
void
|
void
|
||||||
next_record (int done)
|
next_record (int done)
|
||||||
{
|
{
|
||||||
|
gfc_offset fp; /* file position */
|
||||||
|
|
||||||
current_unit->read_bad = 0;
|
current_unit->read_bad = 0;
|
||||||
|
|
||||||
|
@ -1314,8 +1318,12 @@ next_record (int done)
|
||||||
|
|
||||||
current_unit->current_record = 0;
|
current_unit->current_record = 0;
|
||||||
if (current_unit->flags.access == ACCESS_DIRECT)
|
if (current_unit->flags.access == ACCESS_DIRECT)
|
||||||
current_unit->last_record = file_position (current_unit->s)
|
{
|
||||||
/ current_unit->recl;
|
fp = file_position (current_unit->s);
|
||||||
|
/* Calculate next record, rounding up partial records. */
|
||||||
|
current_unit->last_record = (fp + curren_unit->recl - 1)
|
||||||
|
/ current_unit->recl;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
current_unit->last_record++;
|
current_unit->last_record++;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue