From patchwork Thu Jun 26 01:58:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerry DeLisle X-Patchwork-Id: 364230 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 683831400AA for ; Thu, 26 Jun 2014 11:59:11 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=K6gdu2PsaPgt+yvfb7VRbB/LrJ5FY8oOUQ4iY9KLHHC Y6aVoAg5ai/PbbKGgpCTZ1Zl5Q+o8tG+zIGMuAniRVdrRTH9pfvFg7yrj3n3fL2a d8Ea9ENb10v3rOl+nfOuVp2Ot4O5HVv6oSG149nrBiVXolZ2nTjXE8YADormWQZ8 = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=CO5cTgtFjxwnwJaKafJvjGFbbfg=; b=fuFu16i5Ho5ZLxJjz 2W9KEWN72UGqHd5wDu+mQx/zvqaimueF+KthwHFT3gG6rsrsc6sO8eshA96sivSz RfaNDjImbKDEAbSLXXKTfPf0OXgl8nn5zfIelhcMjIwYbIYK/EhE6uuwVIcWrVst ++ptfLR915lpi089X4bZon3aRg= Received: (qmail 17667 invoked by alias); 26 Jun 2014 01:59:02 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 17642 invoked by uid 89); 26 Jun 2014 01:58:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mta31.charter.net Received: from mta31.charter.net (HELO mta31.charter.net) (216.33.127.82) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 26 Jun 2014 01:58:58 +0000 Received: from imp11 ([10.20.200.11]) by mta31.charter.net (InterMail vM.8.01.05.02 201-2260-151-103-20110920) with ESMTP id <20140626015856.RSV6769.mta31.charter.net@imp11>; Wed, 25 Jun 2014 21:58:56 -0400 Received: from mtaout006.msg.strl.va.charter.net ([68.114.190.31]) by imp11 with smtp.charter.net id Jpyw1o0060h5dSU05pywkT; Wed, 25 Jun 2014 21:58:56 -0400 Received: from impout001 ([68.114.189.16]) by mtaout006.msg.strl.va.charter.net (InterMail vM.9.00.010.00 201-2473-137) with ESMTP id <20140626015856.UGPZ23206.mtaout006.msg.strl.va.charter.net@impout001>; Wed, 25 Jun 2014 20:58:56 -0500 Received: from pavi.localdomain ([72.194.69.199]) by impout001 with charter.net id Jpyv1o00J4Hxx8Q01pywPA; Wed, 25 Jun 2014 20:58:56 -0500 X-Authority-Analysis: v=2.1 cv=TOPLSjVa c=1 sm=1 tr=0 a=B1S/AlkX9gmsrZinFLYKFA==:117 a=B1S/AlkX9gmsrZinFLYKFA==:17 a=hOpmn2quAAAA:8 a=MvqziL5F8ecA:10 a=sUYpqjkehcAA:10 a=yUnIBFQkZM0A:10 a=r77TgQKjGQsHNAKrUKIA:9 a=9iDbn-4jx3cA:10 a=cKsnjEOsciEA:10 a=mDV3o1hIAAAA:8 a=QucH22_zEjOhv0oZ_xEA:9 a=wPNLvfGTeEIA:10 a=XAM1Cyd-8wsR3qcDMTkA:9 a=poRQeZ8CDiiKAKmaq7IA:9 a=B_gtTlbzkIoA:10 a=V387imtQsk4A:10 a=UMOWuFUNfwQA:10 X-Auth-id: anZkZWxpc2xlQGNoYXJ0ZXIubmV0 Message-ID: <53AB7E5F.7010205@charter.net> Date: Wed, 25 Jun 2014 18:58:55 -0700 From: Jerry DeLisle User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: gfortran CC: gcc patches Subject: [patch, libgfortran] [4.9/4.10 Regression] Internal read of negative integer broken Hi, This bug has nothing to do with negative numbers as in the description. However, the problem is due to seeking when there are no spaces to skip. I restructured the loop so that the skipping is not done if there are no spaces. Regression tested on x86-64. New test case from the PR. OK for trunk and 4.9? Regards, Jerry 2014-06-25 Jerry DeLisle PR libgfortran/61499 * io/list_read.c (eat_spaces): Use a 'for' loop instead of 'while' loop to skip the loop if there are no bytes left in the string. Only seek if actual spaces can be skipped. Index: io/list_read.c =================================================================== --- io/list_read.c (revision 211765) +++ io/list_read.c (working copy) @@ -387,50 +387,39 @@ eat_spaces (st_parameter_dt *dtp) int c; /* If internal character array IO, peak ahead and seek past spaces. - This is an optimazation to eliminate numerous calls to - next character unique to character arrays with large character - lengths (PR38199). */ - if (is_array_io (dtp)) + This is an optimization unique to character arrays with large + character lengths (PR38199). This code eliminates numerous calls + to next_character. */ + if (is_array_io (dtp) && (dtp->u.p.last_char == EOF - 1)) { gfc_offset offset = stell (dtp->u.p.current_unit->s); - gfc_offset limit = offset + dtp->u.p.current_unit->bytes_left; + gfc_offset i; if (dtp->common.unit) /* kind=4 */ { - gfc_char4_t cc; - limit *= (sizeof (gfc_char4_t)); - do + for (i = 0; i < dtp->u.p.current_unit->bytes_left; i++) { - cc = dtp->internal_unit[offset]; - offset += (sizeof (gfc_char4_t)); - dtp->u.p.current_unit->bytes_left--; + if (dtp->internal_unit[offset + i * sizeof (gfc_char4_t)] + != (gfc_char4_t)' ') + break; } - while (offset < limit && cc == (gfc_char4_t)' '); - /* Back up, seek ahead, and fall through to complete the - process so that END conditions are handled correctly. */ - dtp->u.p.current_unit->bytes_left++; - - cc = dtp->internal_unit[offset]; - if (cc != (gfc_char4_t)' ') - sseek (dtp->u.p.current_unit->s, - offset-(sizeof (gfc_char4_t)), SEEK_SET); } else { - do + for (i = 0; i < dtp->u.p.current_unit->bytes_left; i++) { - c = dtp->internal_unit[offset++]; - dtp->u.p.current_unit->bytes_left--; + if (dtp->internal_unit[offset + i] != ' ') + break; } - while (offset < limit && c == ' '); - /* Back up, seek ahead, and fall through to complete the - process so that END conditions are handled correctly. */ - dtp->u.p.current_unit->bytes_left++; + } - if (dtp->internal_unit[offset] != ' ') - sseek (dtp->u.p.current_unit->s, offset - 1, SEEK_SET); + if (i != 0) + { + sseek (dtp->u.p.current_unit->s, offset + i, SEEK_SET); + dtp->u.p.current_unit->bytes_left -= i; } } + /* Now skip spaces, EOF and EOL are handled in next_char. */ do c = next_char (dtp);