PR fortran/18710
* io/transfer.c (unformatted_read, unformatted_write): width of
a COMPLEX is twice its kind.
gcc/testsuite/
PR fortran/18170
* gfortran.dg/direct_io_3.f90: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@91656
138bc75d-0d04-0410-961f-
82ee72b054a4
+2004-12-02 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
+
+ PR fortran/18170
+ * gfortran.dg/direct_io_3.f90: New test.
+
2004-12-02 Nathan Sidwell <nathan@codesourcery.com>
PR 18758
--- /dev/null
+! { dg-do run }
+! PR 18710 : We used to not read and write the imaginary part of
+! complex numbers
+ COMPLEX C, D
+ DOUBLE COMPLEX E, F
+
+ OPEN(UNIT=9,FILE='PR18710',ACCESS='DIRECT',RECL=132)
+
+ C = (120.0,240.0)
+ WRITE(9,REC=1)C
+ READ(9,REC=1)D
+ if (c /= d) call abort()
+
+ E = (120.0,240.0)
+ WRITE(9,REC=1)E
+ READ(9,REC=1)F
+ if (E /= F) call abort()
+
+ CLOSE(UNIT=9,STATUS='DELETE')
+ END
+2004-12-02 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
+
+ PR fortran/18710
+ * io/transfer.c (unformatted_read, unformatted_write): width of
+ a COMPLEX is twice its kind.
+
2004-12-02 Richard Sandiford <rsandifo@redhat.com>
* configure.ac: Use TL_AC_GCC_VERSION to set gcc_version.
{
void *source;
int w;
+
+ /* Transfer functions get passed the kind of the entity, so we have
+ to fix this for COMPLEX data which are twice the size of their
+ kind. */
+ if (type == BT_COMPLEX)
+ length *= 2;
+
w = length;
source = read_block (&w);
unformatted_write (bt type, void *source, int length)
{
void *dest;
- dest = write_block (length);
- if (dest != NULL)
- memcpy (dest, source, length);
+
+ /* Correction for kind vs. length as in unformatted_read. */
+ if (type == BT_COMPLEX)
+ length *= 2;
+
+ dest = write_block (length);
+ if (dest != NULL)
+ memcpy (dest, source, length);
}