From patchwork Mon Nov 28 14:27:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 700010 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 3tS8Cg6hsHz9vFX for ; Tue, 29 Nov 2016 01:27:42 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Z2nj+rH2"; 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:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=xxW+puchaIna1WWDBhFLYSPE1hrqW6eh9jezXR/g+nEMgft/hclJg orDb2Xl5hi+SWh4yUJ6O78FVSnRWfud138pIQaP1RBZIqjziKVDCRFc5ezr+yMMy cKMALF8+n2O0L93CdmyMC2+l9p0rRn2eXG9ZWlpAmNxQ2e+EVqkDTo= 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:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=En5TQ13Cn5SYIaZL456JSsUNYbU=; b=Z2nj+rH21TdGv6HeHRid yaFh7SrD8601cgpA3adviKg2Q5YlPYVnooyj9qr84dIsuLkIykTCCpq0BQI2vq6H 4wk37N7dF3aNBuLAy6QvuWvrmjXmMw+23Y+TB1Ub0X+grSZmm1rvh530cihoJLNP DDRRt4fZ7PqVmU05jHRqJi0= Received: (qmail 117969 invoked by alias); 28 Nov 2016 14:27:34 -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 117955 invoked by uid 89); 28 Nov 2016 14:27:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, SPF_PASS autolearn=ham version=3.3.2 spammy=symptoms, Hx-languages-length:1795 X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 28 Nov 2016 14:27:23 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id F3D34ACFC for ; Mon, 28 Nov 2016 14:27:20 +0000 (UTC) Date: Mon, 28 Nov 2016 15:27:20 +0100 From: Martin Jambor To: GCC Patches Subject: [RFC] Assert DECL_ABSTRACT_ORIGIN is different from the decl itself Message-ID: <20161128142720.fjw72dtpd2mekftv@virgil.suse.cz> Mail-Followup-To: GCC Patches MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.6.2 (2016-07-01) X-IsSubscribed: yes Hi, one of a number of symptoms of an otherwise unrelated HSA bug I've been debugging today is gcc crashing or hanging in the C++ pretty printer when attempting to emit a warning because dump_decl() ended up in an infinite recursion calling itself on the DECL_ABSTRACT_ORIGIN of the decl it was looking at, which was however the same thing. (It was set to itself on purpose in set_decl_origin_self as a part of final pass, the decl was being printed because it was itself an abstract origin of another one). If someone ever faces a similar problem, the following (untested) patch might save them a bit of time. I have eventually decided not to make it a checking-only assert because it is on a cold path and because at release-build optimization levels, the tail-call is optimized to a jump and thus an infinite loop if the described situation happens, and I suppose an informative ICE is better tan that even for users. What do you think? Would it be reasonable for trunk even now or should I queue it for the next stage1? Thanks, Martin gcc/cp/ 2016-11-28 Martin Jambor * error.c (dump_decl): Add an assert that DECL_ABSTRACT_ORIGIN is not the decl itself. --- gcc/cp/error.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 7bf07c3..1f2ae1a 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -1217,7 +1217,10 @@ dump_decl (cxx_pretty_printer *pp, tree t, int flags) if (! DECL_LANG_SPECIFIC (t)) { if (DECL_ABSTRACT_ORIGIN (t)) - dump_decl (pp, DECL_ABSTRACT_ORIGIN (t), flags); + { + gcc_assert (DECL_ABSTRACT_ORIGIN (t) != t); + dump_decl (pp, DECL_ABSTRACT_ORIGIN (t), flags); + } else pp_string (pp, M_("")); }