From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 87740 invoked by alias); 17 Oct 2018 21:17:36 -0000 Mailing-List: contact fortran-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: fortran-owner@gcc.gnu.org Received: (qmail 87719 invoked by uid 89); 17 Oct 2018 21:17:35 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.3 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=H*f:CAGkQGi, H*i:CAGkQGi, H*f:sk:Rq08DYL, transdeclc X-HELO: mx-relay61-hz2.antispameurope.com Received: from mx-relay61-hz2.antispameurope.com (HELO mx-relay61-hz2.antispameurope.com) (94.100.136.161) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 17 Oct 2018 21:17:34 +0000 Return-Path: Received: from s041.bre.qsc.de ([195.90.7.81]) by mx-relay61-hz2.antispameurope.com; Wed, 17 Oct 2018 23:17:31 +0200 Received: from tux.net-b.de (port-92-194-24-29.dynamic.qsc.de [92.194.24.29]) by s041.bre.qsc.de (Postfix) with ESMTPSA id F06842C00C7; Wed, 17 Oct 2018 23:17:29 +0200 (CEST) Subject: Re: [Patch, fortran] PR58618 - Wrong code with character substring and ASSOCIATE To: Paul Richard Thomas , "fortran@gcc.gnu.org" , gcc-patches References: From: Tobias Burnus Message-ID: Date: Wed, 17 Oct 2018 21:17:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------97814E571F85F94867B41982" X-cloud-security-sender:burnus@net-b.de X-cloud-security-recipient:fortran@gcc.gnu.org X-cloud-security-Virusscan:CLEAN X-cloud-security-disclaimer: This E-Mail was scanned by E-Mailservice on mx-relay61-hz2.antispameurope.com with 4DA45547127 X-cloud-security-connect: s041.bre.qsc.de[195.90.7.81], TLS=1, IP=195.90.7.81 X-cloud-security:scantime:1.211 X-IsSubscribed: yes X-SW-Source: 2018-10/txt/msg00083.txt.bz2 This is a multi-part message in MIME format. --------------97814E571F85F94867B41982 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-length: 1381 Hi Paul, Paul Richard Thomas wrote: > This problem concerned associate targets being substrings. It turns > out that they are returned as pointer types (with a different cast for > unity based substrings ***sigh***) and so can be assigned directly to > the associate name. The patch quite simply removed the condition that > such targets be allocatable, pointer or dummy. > I noticed in the course of working up the testcase that > character (:), pointer :: ptr => NULL() > character (6), target :: tgt = 'lmnopq' > ptr => tgt > print *, len (ptr), ptr > end > ICEs on the NULL initialization of the pointer but works fine if this > is removed. Has this already been posted as a PR? I leave it to Dominique to search for a PR; otherwise, I believe the attach patch fixes the issue. – It just needs someone to package it with a test case, regtest and commit it. > Bootstrapped and regtested on FC28/x86_64 - OK for trunk? OK – thanks for the fix. Tobias > 2018-10-17 Paul Thomas > > PR fortran/58618 > * trans-stmt.c (trans_associate_var): All strings that return > as pointer types can be assigned directly to the associate > name so remove 'attr' and the condition that uses it. > > 2018-10-17 Paul Thomas > > PR fortran/58618 > * gfortran.dg/associate_45.f90 : New test. --------------97814E571F85F94867B41982 Content-Type: text/x-patch; name="null-init.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="null-init.diff" Content-length: 849 diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index b0c12e5fc38..88f9f570725 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -1762,7 +1762,8 @@ gfc_get_symbol_decl (gfc_symbol * sym) gfc_finish_var_decl (length, sym); if (!sym->attr.associate_var && TREE_CODE (length) == VAR_DECL - && sym->value && sym->value->ts.u.cl->length) + && sym->value && sym->value->expr_type != EXPR_NULL + && sym->value->ts.u.cl->length) { gfc_expr *len = sym->value->ts.u.cl->length; DECL_INITIAL (length) = gfc_conv_initializer (len, &len->ts, @@ -1772,7 +1773,7 @@ gfc_get_symbol_decl (gfc_symbol * sym) DECL_INITIAL (length)); } else - gcc_assert (!sym->value); + gcc_assert (!sym->value || sym->value->expr_type == EXPR_NULL); } gfc_finish_var_decl (decl, sym); --------------97814E571F85F94867B41982--