From patchwork Tue Oct 26 00:34:07 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerry DeLisle X-Patchwork-Id: 69161 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]) by ozlabs.org (Postfix) with SMTP id D976EB70A9 for ; Tue, 26 Oct 2010 15:09:53 +1100 (EST) Received: (qmail 23605 invoked by alias); 26 Oct 2010 04:09:44 -0000 Received: (qmail 23564 invoked by uid 22791); 26 Oct 2010 04:09:43 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, TW_CP X-Spam-Check-By: sourceware.org Received: from out01.roch.ny.frontiernet.net (HELO out01.roch.ny.frontiernet.net) (66.133.183.226) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 26 Oct 2010 04:09:37 +0000 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEACO+xUxA6lwO/2dsb2JhbAChVcEhhUgEhFQ Received: from relay01.roch.ny.frontiernet.net ([66.133.182.164]) by out01.roch.ny.frontiernet.net with ESMTP; 26 Oct 2010 00:33:54 +0000 X-Previous-IP: 64.234.92.14 Received: from quava.localdomain (host-64-234-92-14.nctv.com [64.234.92.14]) by relay01.roch.ny.frontiernet.net (Postfix) with ESMTPA id 7FFCA3FEB9; Tue, 26 Oct 2010 00:33:52 +0000 (UTC) Message-ID: <4CC621FF.3010103@frontier.com> Date: Mon, 25 Oct 2010 17:34:07 -0700 From: Jerry DeLisle User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.9) Gecko/20100921 Fedora/3.1.4-1.fc13 Thunderbird/3.1.4 MIME-Version: 1.0 To: gfortran CC: gcc patches Subject: [patch, libgfortran] PR 46010 - I/O: Namelist-reading bug 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 Hi all, The attached patch is simple and fairly safe. It adds a couple of conditions to assure that nml_parse_qualifier sets the end index for the loop spec. I will add the two test cases in the PR to our testsuite. Regression tested on x86-64. OK for trunk? Jerry 2010-10-20 Jerry DeLisle PR libgfortran/46010 * io/list_read.c (nml_parse_qualifier): Add additional conditions for setting the end index for loop specification. Fix some whitespace. Index: list_read.c =================================================================== --- list_read.c (revision 165900) +++ list_read.c (working copy) @@ -2105,8 +2105,10 @@ nml_parse_qualifier (st_parameter_dt *dtp, descrip /* If -std=f95/2003 or an array section is specified, do not allow excess data to be processed. */ - if (is_array_section == 1 - || !(compile_options.allow_std & GFC_STD_GNU)) + if (is_array_section == 1 + || !(compile_options.allow_std & GFC_STD_GNU) + || !dtp->u.p.ionml->touched + || dtp->u.p.ionml->type == BT_DERIVED) ls[dim].end = ls[dim].start; else dtp->u.p.expanded_read = 1; @@ -2121,12 +2123,12 @@ nml_parse_qualifier (st_parameter_dt *dtp, descrip } if (is_array_section == 1 && dtp->u.p.expanded_read == 1) - { + { int i; dtp->u.p.expanded_read = 0; for (i = 0; i < dim; i++) ls[i].end = ls[i].start; - } + } /* Check the values of the triplet indices. */ if ((ls[dim].start > (ssize_t) GFC_DIMENSION_UBOUND(ad[dim])) Index: write.c =================================================================== --- write.c (revision 165900) +++ write.c (working copy) @@ -65,7 +65,7 @@ memcpy4 (gfc_char4_t *dest, const char *source, in /* Write out default char4. */ static void -write_default_char4 (st_parameter_dt *dtp, gfc_char4_t *source, +write_default_char4 (st_parameter_dt *dtp, const gfc_char4_t *source, int src_len, int w_len) { char *p;