Bug 37753 - [4.4 Regression] Convert="BIG_ENDIAN" reverses character
Summary: [4.4 Regression] Convert="BIG_ENDIAN" reverses character
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libfortran (show other bugs)
Version: 4.4.0
: P4 major
Target Milestone: 4.4.0
Assignee: Thomas Koenig
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2008-10-06 19:32 UTC by Thomas Koenig
Modified: 2008-10-09 21:57 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-10-07 20:41:02


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Koenig 2008-10-06 19:32:41 UTC
From http://gcc.gnu.org/ml/fortran/2008-10/msg00045.html :

$ cat foo.f90
 character(len=16) :: string, string2
  string='BIG_ENDIAN'

open(unit=13,form='unformatted',file='gftest.dat',convert='big_endian',status='UNKNOWN')
  write(13) string
  close(13)
end
$ gfortran foo.f90
$ ./a.out
$ od -t x1 -t a gftest.dat
0000000 00 00 00 10 20 20 20 20 20 20 4e 41 49 44 4e 45
        nul nul nul dle  sp  sp  sp  sp  sp  sp   N   A   I   D   N   E
0000020 5f 47 49 42 00 00 00 10
          _   G   I   B nul nul nul dle
0000030
Comment 1 Jerry DeLisle 2008-10-07 02:54:27 UTC
Thomas, any ideas and do you have time to investigate this?
Comment 2 Thomas Koenig 2008-10-07 20:41:02 UTC
(In reply to comment #1)
> Thomas, any ideas and do you have time to investigate this?

The problem is right at the beginning of write_unformatted
and read_unformatted.  I think we need to select the normal
write/read on kind==1, not on size==1,  but I will need to do some
more thinking on this.
Comment 3 Thomas Koenig 2008-10-09 19:30:19 UTC
Subject: Bug 37753

Author: tkoenig
Date: Thu Oct  9 19:28:58 2008
New Revision: 141008

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=141008
Log:
2008-10-09  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR libfortran/37753
	* io/transfer.c (unformatted_read):  CONVERT_NATIVE
	is the usual case.  Check for kind==1 for non-byte-reversing
	operation.
	(unformatted_write):  Likewise.

2008-10-09  Thomas Koenig  <tkoenig@gcc.gnu.org>

	PR libfortran/37753
	* gfortran.dg/convert_2.f90:  New test case.


Added:
    trunk/gcc/testsuite/gfortran.dg/convert_2.f90
Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/io/transfer.c

Comment 4 Thomas Koenig 2008-10-09 21:57:37 UTC
Fixed. Closing.