https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61640
Bug ID: 61640 Summary: KIND=4 Character Array Internal Unit Read Fail Product: gcc Version: 4.10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libfortran Assignee: jvdelisle at gcc dot gnu.org Reporter: jvdelisle at gcc dot gnu.org The following fails on the read. Found while working on another bug. program read_internal integer :: x(9),i,iostat character(len=512) :: iomsg character(kind=4,len=30), dimension(3) :: source source=[4_" 1 1 -1",4_" 1 -1 1",4_" -1 1 1"] print *, (trim(source(i)), i=1,3) read(source,*) (x(i), i=1,6) ! This read fails for KIND=4 character end program read_internal The fix is: Index: list_read.c =================================================================== --- list_read.c (revision 212104) +++ list_read.c (working copy) @@ -273,7 +273,7 @@ next_char_internal (st_parameter_dt *dtp) /* Get the next character and handle end-of-record conditions. */ if (dtp->common.unit) /* Check for kind=4 internal unit. */ - length = sread (dtp->u.p.current_unit->s, &c, sizeof (gfc_char4_t)); + length = sread (dtp->u.p.current_unit->s, &c, 1); else { char cc; Index: unix.c =================================================================== --- unix.c (revision 212104) +++ unix.c (working copy) @@ -808,10 +808,10 @@ mem_read4 (stream * s, void * buf, ssize_t nbytes) void *p; int nb = nbytes; - p = mem_alloc_r (s, &nb); + p = mem_alloc_r4 (s, &nb); if (p) { - memcpy (buf, p, nb); + memcpy (buf, p, nb * 4); return (ssize_t) nb; } else