[Bug fortran/52724] Internal read with character(kind=4) data
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52724 Thomas Koenig changed: What|Removed |Added Status|NEW |RESOLVED Resolution||FIXED --- Comment #7 from Thomas Koenig 2012-10-28 20:51:37 UTC --- Fixed on trunk, closing.
[Bug fortran/52724] Internal read with character(kind=4) data
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52724 --- Comment #6 from Thomas Koenig 2012-09-29 17:38:50 UTC --- Author: tkoenig Date: Sat Sep 29 17:38:46 2012 New Revision: 191854 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=191854 Log: 2012-09-29 Thomas König PR fortran/52724 * list_read.c (next_char): Handle kind=4 characters. * unix.c (open_internal4): Correct lenth of internal file. 2012-09-29 Thomas König PR fortran/52724 * gfortran.dg/internal_readwrite_3.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/internal_readwrite_3.f90 Modified: trunk/gcc/testsuite/ChangeLog trunk/libgfortran/ChangeLog trunk/libgfortran/io/list_read.c trunk/libgfortran/io/unix.c
[Bug fortran/52724] Internal read with character(kind=4) data
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52724 --- Comment #5 from Thomas Koenig 2012-09-24 18:07:17 UTC --- This patch looks promising: Index: list_read.c === --- list_read.c (Revision 191649) +++ list_read.c (Arbeitskopie) @@ -199,9 +199,16 @@ next_char (st_parameter_dt *dtp) if (is_internal_unit (dtp)) { - char cc; - length = sread (dtp->u.p.current_unit->s, &cc, 1); - c = cc; + /* Check for kind=4 internal unit. */ + if (dtp->common.unit) + length = sread (dtp->u.p.current_unit->s, &c, sizeof (gfc_char4_t)); + else + { + char cc; + length = sread (dtp->u.p.current_unit->s, &cc, 1); + c = cc; + } + if (length < 0) { generate_error (&dtp->common, LIBERROR_OS, NULL); Index: unix.c === --- unix.c (Revision 191649) +++ unix.c (Arbeitskopie) @@ -959,7 +959,7 @@ open_internal4 (char *base, int length, gfc_offset s->buffer = base; s->buffer_offset = offset; - s->active = s->file_length = length; + s->active = s->file_length = length * sizeof (gfc_char4_t); s->st.vptr = &mem4_vtable;
[Bug fortran/52724] Internal read with character(kind=4) data
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52724 --- Comment #4 from Thomas Koenig 2012-04-08 08:55:42 UTC --- Yes, my original test case was bogus. Slightly reduced test case: program main implicit none integer :: i character(len=100,kind=4) :: buffer buffer = 4_"123" read(buffer,*) i print *,i end program main
[Bug fortran/52724] Internal read with character(kind=4) data
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52724 Tobias Burnus changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2012-04-02 CC||burnus at gcc dot gnu.org Ever Confirmed|0 |1 --- Comment #3 from Tobias Burnus 2012-04-02 20:01:08 UTC --- (In reply to comment #2) > I am curious about what this line is doing: character buffer4(100) buffer4 = 4_'123' Well, that line does what it should do: It assign the value '123' - trimmed to one character (namely '1') to the array buffer4. The array4 then contains 100 times the value '1'. (In reply to comment #0) > read(buffer4,*) i > print *,i > end > ig25@linux-fd1f:~/Krempel/Opt> gfortran foo.f90 > ig25@linux-fd1f:~/Krempel/Opt> ./a.out >1 And seemingly that's also what Thomas gets. * * * (In reply to comment #2) > buffer4 is a kind=1 variable. have you tried: > character(kind=4) buffer4(100) ? Well, with len=1,kind=4 or with len=2,kind=2 one gets, respectively, 1 and 12 - which is the expected result. However, the following fails: character(len=2,kind=4) buffer4(100) integer i buffer4 = 4_'123' read(buffer4,*) i print *,i end Fortran runtime error: Bad integer for item 1 in list input Printing the value of the array as "print *, buffer4", one gets the expected " 121212" as output. And reading the line as read(buffer4,'(i5)') i works and yields "12". Only when replacing the formatted read by a list-directed read, it fails.
[Bug fortran/52724] Internal read with character(kind=4) data
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52724 --- Comment #2 from Jerry DeLisle 2012-03-29 01:05:20 UTC --- I am curious about what this line is doing: buffer4 = 4_'123' buffer4 is a kind=1 variable. have you tried: character(kind=4) buffer4(100) ?
[Bug fortran/52724] Internal read with character(kind=4) data
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52724 Thomas Koenig changed: What|Removed |Added CC||jvdelisle at gcc dot ||gnu.org --- Comment #1 from Thomas Koenig 2012-03-26 16:14:36 UTC --- Hi Jerry, do you have any idea?