From patchwork Fri Dec 2 17:00:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janus Weil X-Patchwork-Id: 702039 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 3tVgQt4m2Bz9t1B for ; Sat, 3 Dec 2016 04:01:09 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="X2o3C1uo"; dkim-atps=neutral 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:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; q=dns; s=default; b=dtuXbT20yHQkZYD JVaBceqqDoysnf1V4gbePs/5S4px7AI/HCqzlx6YaIciZonNzs9Uh/tBuhwadb+7 +sW5zhDTjd59Fah3S8zNYtVDLG2FnHWguLKJP/jBq6FKd2KBffbib3Qe0Qo2pv8i f0aVCXFVOX6N8LTryXghAsbQDkF8= 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:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; s=default; bh=OnXjEo8CFTCj2MGLHWR3g I/DtM0=; b=X2o3C1uo/+ckYpX9Gdc5yn7XI50YSxSce0iAE1x+ELrBU5mdvEVFm jou1nX1evgrp0WXraRGcsxKuifBawoPiMR5RE8wD+qF/rcrsQ7pa1ZzS5+m9ksUF yJMPy3I5GnMWt5kj++UD6Az5CD+1BUzrwmGOY1vqRFDzizRywB126w= Received: (qmail 113792 invoked by alias); 2 Dec 2016 17:01:01 -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 113767 invoked by uid 89); 2 Dec 2016 17:01:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL, BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=HTo:D*washington.edu X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-yw0-f194.google.com Received: from mail-yw0-f194.google.com (HELO mail-yw0-f194.google.com) (209.85.161.194) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 02 Dec 2016 17:00:51 +0000 Received: by mail-yw0-f194.google.com with SMTP id r204so22134412ywb.3; Fri, 02 Dec 2016 09:00:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=K3NB45UrDYmUv1Z+uJmgGurtHPPjyS/J+y2olpkkiOY=; b=THv/QDef/6Hf9B7eIZsMktFRoJPAXNNDh1RWYTD86CIvKTjTGQHsbuNS8WMkkye6P7 iqXkqaX24XU68gCRuizTJDzgLje6jsCAIaCpIONT89KTi8Q7Wg12w6TCUaQCMln8jHoG rIWF7Eb7aKebMRQwMWlhEE+Sf4ZwhDDB4JzWwYrD26+kfzSHHOW0s39HtDF7jayoigPw crJr9qraBCBxG2wKQaKiv22rgSzcfjkUda3D1+7hNjtBpZpuwN/79gSwqX0nSAf9hcGc DLz0eEILf8wd7iWXMS4LVfkD4G5seUXChqFXrNWRUHqA2X5l4O/yfcbAarlZA/540NAN AjSw== X-Gm-Message-State: AKaTC005UT1lj11A6QdN8GvAjfXsgZtPo331MufgIclVkH4sRsUSU1vnKjGzHUzRJ4pHtEH27AFLbP87XgjjOg== X-Received: by 10.13.226.85 with SMTP id l82mr45190527ywe.43.1480698049265; Fri, 02 Dec 2016 09:00:49 -0800 (PST) MIME-Version: 1.0 Received: by 10.129.51.145 with HTTP; Fri, 2 Dec 2016 09:00:48 -0800 (PST) In-Reply-To: <20161202163014.GA46189@troutmask.apl.washington.edu> References: <20161202013354.GA42106@troutmask.apl.washington.edu> <20161202163014.GA46189@troutmask.apl.washington.edu> From: Janus Weil Date: Fri, 2 Dec 2016 18:00:48 +0100 Message-ID: Subject: Re: [PATCH] PR fortran/78618 -- RANK() should not ICE To: Steve Kargl Cc: kargl@uw.edu, gfortran , gcc-patches 2016-12-02 17:30 GMT+01:00 Steve Kargl : > On Fri, Dec 02, 2016 at 04:47:19PM +0100, Janus Weil wrote: >> Hi Steve, >> >> 2016-12-02 2:33 GMT+01:00 Steve Kargl : >> > The attached patch fixes an ICE, a nearby whitespace issue, and >> > removed the ATTRIBUTE_UNUSED tag. THe change has passed regression >> > testing on x86_64-*-freebsd. Ok to commit? >> >> huh, I don't really understand why the argument of RANK is detected to >> be an EXPR_FUNCTION for the test case at hand. Shouldn't it rather be >> an EXPR_CONSTANT? >> >> Some debugging in gfc_check_rank shows that a->symtree->n.sym indeed >> is the symbol "c" (as expected), but that clearly is not a function, >> so it seems to me that the actual bug here is that a->expr_type is set >> incorrectly ...? > > I found that it is the function __convert_s4_s1. That's strange. If we see different things here, maybe we are running into some kind of undefined behavior (possibly related to gfc_bad_expr?). Anyway, after some more debugging I came to the conclusion that what actually fails is the error propagation, which seems to be broken in gfc_check_assign and can be fixed like this: This also avoids the ICE and I think is the proper way to fix this ... Cheers, Janus Index: gcc/fortran/expr.c =================================================================== --- gcc/fortran/expr.c (revision 243194) +++ gcc/fortran/expr.c (working copy) @@ -3314,9 +3314,9 @@ gfc_check_assign (gfc_expr *lvalue, gfc_expr *rval if (lvalue->ts.type == BT_CHARACTER && rvalue->ts.type == BT_CHARACTER) { if (lvalue->ts.kind != rvalue->ts.kind && allow_convert) - gfc_convert_chartype (rvalue, &lvalue->ts); - - return true; + return gfc_convert_chartype (rvalue, &lvalue->ts); + else + return true; } if (!allow_convert)