From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27519 invoked by alias); 24 Sep 2012 18:07:54 -0000 Received: (qmail 27341 invoked by uid 48); 24 Sep 2012 18:07:18 -0000 From: "tkoenig at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/52724] Internal read with character(kind=4) data Date: Mon, 24 Sep 2012 18:07:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: tkoenig at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-09/txt/msg01972.txt.bz2 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;