re PR fortran/34876 (Can't read/write array sections with negative stride not specified)

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.

From-SVN: r131848
This commit is contained in:
Jerry DeLisle 2008-01-25 23:34:53 +00:00
parent 42cd23cb28
commit 4152bc263e
2 changed files with 23 additions and 3 deletions

View File

@ -1,3 +1,10 @@
2008-01-24 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.
2008-01-24 David Edelsohn <edelsohn@gnu.org> 2008-01-24 David Edelsohn <edelsohn@gnu.org>
* configure: Regenerate. * configure: Regenerate.

View File

@ -638,6 +638,14 @@ write_buf (st_parameter_dt *dtp, void *buf, size_t nbytes)
return FAILURE; return FAILURE;
} }
if (buf == NULL && nbytes == 0)
{
char *p;
p = write_block (dtp, dtp->u.p.current_unit->recl);
memset (p, 0, dtp->u.p.current_unit->recl);
return SUCCESS;
}
if (swrite (dtp->u.p.current_unit->s, buf, &nbytes) != 0) if (swrite (dtp->u.p.current_unit->s, buf, &nbytes) != 0)
{ {
generate_error (&dtp->common, LIBERROR_OS, NULL); generate_error (&dtp->common, LIBERROR_OS, NULL);
@ -648,7 +656,6 @@ write_buf (st_parameter_dt *dtp, void *buf, size_t nbytes)
dtp->u.p.current_unit->bytes_left -= (gfc_offset) nbytes; dtp->u.p.current_unit->bytes_left -= (gfc_offset) nbytes;
return SUCCESS; return SUCCESS;
} }
/* Unformatted sequential. */ /* Unformatted sequential. */
@ -1507,10 +1514,16 @@ transfer_array (st_parameter_dt *dtp, gfc_array_char *desc, int kind,
extent[n] = desc->dim[n].ubound + 1 - desc->dim[n].lbound; extent[n] = desc->dim[n].ubound + 1 - desc->dim[n].lbound;
/* If the extent of even one dimension is zero, then the entire /* If the extent of even one dimension is zero, then the entire
array section contains zero elements, so we return. */ array section contains zero elements, so we return after writing
a zero array record. */
if (extent[n] <= 0) if (extent[n] <= 0)
{
data = NULL;
tsize = 0;
dtp->u.p.transfer (dtp, iotype, data, kind, size, tsize);
return; return;
} }
}
stride0 = stride[0]; stride0 = stride[0];