[patch, libgfortran] PR 31915 - fix reading/writing of real(10) variables with convert="SWAP"

Tobias Burnus burnus@net-b.de
Mon May 14 20:15:00 GMT 2007


:ADDPATCH fortran:

The following was failing:

  real(10) :: a,b
  open(10,convert="swap",form="unformatted")
  write(10) a
  backspace 10
  read (10) b
  if (a /= b) call abort


real(10) == long double on my machine; sizeof(long double) == 16 and
kind == 10. Therefore, we wrote/read to few bytes from the unformatted file.

Test case:  gfortran.dg/unf_io_convert_3.f90. Ask Dominique or Jerry why
this test is not used.

Build and regression tested on x86_64-unknown-linux-gnu.

Ok for the trunk? Ok for GCC 4.2.1?

Tobias


PS: This does not fix all problems. If I run valgrind on the produced
a.out, I still get the following output.

==28541== Syscall param write(buf) points to uninitialised byte(s)
==28541==    at 0x5601550: write (in /lib64/libc-2.5.so)
==28541==    by 0x4EBF610: do_write (unix.c:336)
==28541==    by 0x4EBF6B1: fd_flush (unix.c:386)
==28541==    by 0x4EB3512: _gfortran_st_backspace (file_pos.c:230)
==28541==    by 0x400AF1: MAIN__ (in /dev/shm/a.out)
==28541==    by 0x400D8B: main (fmain.c:22)
==28541==  Address 0x40517E1 is 153 bytes inside a block of size 8,344
alloc'd
==28541==    at 0x4C22D06: malloc (in
/usr/lib64/valgrind/amd64-linux/vgpreload_memcheck.so)
==28541==    by 0x4E3EFB8: _gfortrani_get_mem (memory.c:53)
==28541==    by 0x4EC0079: fd_to_stream (unix.c:1043)
==28541==    by 0x4EB9574: _gfortrani_new_unit (open.c:376)
==28541==    by 0x4EB9BDA: _gfortran_st_open (open.c:561)
==28541==    by 0x400A66: MAIN__ (in /dev/shm/a.out)
==28541==    by 0x400D8B: main (fmain.c:22)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: convert2.diff
Type: text/x-patch
Size: 1080 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20070514/b5b37320/attachment.bin>


More information about the Fortran mailing list