From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32109 invoked by alias); 9 Mar 2007 12:56:01 -0000 Received: (qmail 31645 invoked by uid 48); 9 Mar 2007 12:55:50 -0000 Date: Fri, 09 Mar 2007 12:56:00 -0000 Message-ID: <20070309125550.31644.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug libfortran/31099] [4.3/4.2 regression] Runtime error on legal code using RECL In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "burnus at gcc dot gnu dot org" 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: 2007-03/txt/msg00725.txt.bz2 ------- Comment #3 from burnus at gcc dot gnu dot org 2007-03-09 12:55 ------- I was checking where bytes_left is set: open.c: u->bytes_left = 0; This is the default setting in new_unit (/* Open an unused unit. */) It is also set to 0 in file_pos.c (two places). In list_read.c's next_char it is set to current_unit->recl; And in transfer.c: - read_block - write_block (but only if stdout/stderr or default reclen, otherwise a ERROR_EOR error is generated, but this is not the error of this PR.) - us_read - us_write: This one is also not called for this PR - next_record_w: Not for unformatted The problem seems to be that bytes_left == 0 from the initial setting in new_unit as no data has been written. And as 4bytes have to be written, nbytes = 4 > bytes_left. Note: The same problem occurs if one tries to read from a file which has been written by gfortran-4.1. In this case the error condition is in: transfer.c's read_block_direct: if (dtp->u.p.current_unit->flags.has_recl) { to_read_record = *nbytes > (size_t) dtp->u.p.current_unit->bytes_left ? *nbytes : (size_t) dtp->u.p.current_unit->bytes_left; short_record = 1; } else { to_read_record = *nbytes; short_record = 0; } This check has been introduced by the same patch. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31099