From patchwork Sun Feb 3 21:04:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 1035644 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-495203-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gmx.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="qvlW6PJJ"; dkim-atps=neutral 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 43t3Hk455Cz9s3x for ; Mon, 4 Feb 2019 08:04:26 +1100 (AEDT) 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=ESgQXpQCPCGsNWRUN7sK+uiddSdhxx7nPTticwq/dig 5YOX7eUVgobVY59QyD2MTfEfvNifjEgsMh2/sy41PrNr7YJwMSTYEmbLwJulCbHq IGQGr4Xegxph6MNwPcDw2T3xvT7OfgaUfeJnTViO1N2gREztlCn1k5kIVJ/xqPl0 = 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=cIcAyLTNYRpnSA7WVhQv7V2hCME=; b=qvlW6PJJJ9NbMojGm lY9ROHIIvgoCrJJ2Q1gcA5XtvWbhuIUi5Ukyg834TkbeeOBZ28B16XuVjHwQL+9j IJx27BszguX5h4KvDfIEGh9/+iWdpntFqglSE2Z4clt4bJXgUyKERaslXPyLIrtQ sKhjvS1Eky4WIph74CeX2+wX8Q= Received: (qmail 94480 invoked by alias); 3 Feb 2019 21:04:17 -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 94463 invoked by uid 89); 3 Feb 2019 21:04:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.8 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=Copy, D*gmx.de, transfer X-HELO: mout.gmx.net Received: from mout.gmx.net (HELO mout.gmx.net) (212.227.15.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 03 Feb 2019 21:04:14 +0000 Received: from proton.at.home ([79.251.10.126]) by mail.gmx.com (mrgmx002 [212.227.17.190]) with ESMTPSA (Nemesis) id 0MMk99-1gmGCi1Lih-008Ywm; Sun, 03 Feb 2019 22:04:11 +0100 Message-ID: <5C575745.60609@gmx.de> Date: Sun, 03 Feb 2019 22:04:05 +0100 From: Harald Anlauf User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: gfortran CC: gcc-patches@gcc.gnu.org Subject: [PR fortran/89077, patch] - ICE using * as len specifier for character parameter The attached patch fixes an ICE-on-valid that probably goes back to rev.128130. Apparently the patch applied back then did not check this code path which resulted in a NULL pointer dereference. This is remedied by the new testcase base on comment #0 in this PR. The PR mentions another wrong-code issue to be addressed separately. OK for trunk? And shall this fix be backported? Thanks, Harald 2019-02-03 Harald Anlauf PR fortran/89077 * decl.c (add_init_expr_to_sym): Copy length of string initializer to declared symbol. 2019-02-03 Harald Anlauf PR fortran/89077 * gfortran.dg/pr89077.f90: New test. Index: gcc/testsuite/gfortran.dg/pr89077.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr89077.f90 (nonexistent) +++ gcc/testsuite/gfortran.dg/pr89077.f90 (working copy) @@ -0,0 +1,11 @@ +! { dg-do run } +! +! PR fortran/89077 - ICE using * as len specifier for character parameter + +program test + implicit none + integer :: i + character(*), parameter :: s = 'abcdef' + character(*), parameter :: t = transfer ([(s(i:i), i=1,len(s))], s) + if (len (t) /= len (s) .or. t /= s) stop 1 +end Index: gcc/fortran/decl.c =================================================================== --- gcc/fortran/decl.c (revision 268502) +++ gcc/fortran/decl.c (working copy) @@ -1921,7 +1921,7 @@ } else if (init->ts.u.cl && init->ts.u.cl->length) sym->ts.u.cl->length = - gfc_copy_expr (sym->value->ts.u.cl->length); + gfc_copy_expr (init->ts.u.cl->length); } } /* Update initializer character length according symbol. */