From patchwork Mon Oct 8 13:14:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Richard Thomas X-Patchwork-Id: 980561 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-487129-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="r0ANoPo5"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="gIafPI9K"; 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 42TLRm490jz9sBk for ; Tue, 9 Oct 2018 00:14:28 +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 :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=W7fIwmj5Rw0+KtijdxZaYYb0+XHMeVpRljBWi+jLRP8dP2 bpRrQnIiOMnzX3YFMCckRaVeZqae903y8DzyDCq2eGus2/eh6Bjplh9lneKI4Nss o8y+4bEVUpgi9Uy6JexzU0MVdiAeIMMuahoerlz8M73ml5a5jHNLPvvaZ8Ws4= 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 :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=whGZ0Hyr9R2sdLx9CnvQXy2RJi8=; b=r0ANoPo5kfp0eyj3fdsW CdmuIfd2REr/NumHuZZD6H7ftzjJywta8PWPCG+bU8GjSMSRVGFt9IVq+wz4f8n7 FMJF2Uicb3MA84oRMQ/tSB2jWeeliNVaXcKfhzq80S+hh+jMHlMIw6MEz0FsM4lC cbOfIy2KsBOWp2vSE/kRBD4= Received: (qmail 10686 invoked by alias); 8 Oct 2018 13:14:19 -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 10661 invoked by uid 89); 8 Oct 2018 13:14:18 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-6.1 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=weil, Hx-languages-length:1826, thereby X-HELO: mail-yb1-f170.google.com Received: from mail-yb1-f170.google.com (HELO mail-yb1-f170.google.com) (209.85.219.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 08 Oct 2018 13:14:17 +0000 Received: by mail-yb1-f170.google.com with SMTP id w80-v6so8231678ybe.10; Mon, 08 Oct 2018 06:14:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=RhP4v7hm3kSnZUub2DN7mAR+aAwXvtdfVJLO2/18+d8=; b=gIafPI9Kxau55B3iG7lPJ03CEn41WhxdI+uK75lWPn5TbbbAxbPKGbbmzWYzxEy6J4 y/vFD6JJchP1t6MOC5H7lLEGFMbUTfuPMLIu2ehJtrMi78kyA7CfY/MRdaj5O+loQJYN 1bH2XBB7VN90MdH4M0hvsrRm3QTCUEgCISC86XUzvm0tMP7GdrWfcHnVjHRBV1kdiDSK Dk/3rB1/I1zt7tywoc7npHjJ3h3upaKzes1FCqqLhE5+zDxr18aNnj/O0+xpmTobzWt2 RlI/FChUuyp9WYerVq4cGdgyxCpeWRbGKMZB5IguSjp6VwO3531Ej7rxNHhmadHneZvc HciA== MIME-Version: 1.0 From: Paul Richard Thomas Date: Mon, 8 Oct 2018 14:14:03 +0100 Message-ID: Subject: {Patch, fortran] PR86372 - [8/9 Regression] Segfault on ASSOCIATE statement with CHARACTER variable To: "fortran@gcc.gnu.org" , gcc-patches I have fixed this as 'obvious' on 8-branch(r264925) and trunk(r264915). Paul 2018-10-08 Paul Thomas Backport from trunk PR fortran/86372 * trans-stmt.c (trans_associate_var): Character associate names with variable string length do not have to be deferred length for the string length to be set, if variable. 2018-10-08 Paul Thomas Backport from trunk PR fortran/86372 * gfortran.dg/associate_41.f90: New test. Index: gcc/fortran/trans-stmt.c =================================================================== *** gcc/fortran/trans-stmt.c (revision 264912) --- gcc/fortran/trans-stmt.c (working copy) *************** trans_associate_var (gfc_symbol *sym, gf *** 1885,1891 **** } if (sym->ts.type == BT_CHARACTER - && sym->ts.deferred && !sym->attr.select_type_temporary && VAR_P (sym->ts.u.cl->backend_decl) && se.string_length != sym->ts.u.cl->backend_decl) --- 1885,1890 ---- Index: gcc/testsuite/gfortran.dg/associate_41.f90 =================================================================== *** gcc/testsuite/gfortran.dg/associate_41.f90 (nonexistent) --- gcc/testsuite/gfortran.dg/associate_41.f90 (working copy) *************** *** 0 **** --- 1,25 ---- + ! { dg-do run } + ! + ! Test the fix for PR86372 in which the associate name string length was + ! not being set, thereby causing a segfault. + ! + ! Contributed by Janus Weil + ! + program xxx + + character(len=50) :: s + + s = repeat ('*', len(s)) + call sub(s) + if (s .ne. '**'//'123'//repeat ('*', len(s) - 5)) stop 1 + + contains + + subroutine sub(str) + character(len=*), intent(inout) :: str + associate (substr => str(3:5)) + substr = '123' + end associate + end subroutine + + end