From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 131009 invoked by alias); 24 Aug 2015 11:44:45 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 130999 invoked by uid 89); 24 Aug 2015 11:44:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.4 required=5.0 tests=AWL,BAYES_00,FROM_12LTRDOM,KAM_MXURI,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS autolearn=no version=3.3.2 X-HELO: mail.ud10.udmedia.de Received: from ud10.udmedia.de (HELO mail.ud10.udmedia.de) (194.117.254.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 24 Aug 2015 11:44:42 +0000 Received: (qmail 15304 invoked from network); 24 Aug 2015 13:44:38 +0200 Received: from ip5b41f88a.dynamic.kabel-deutschland.de (HELO x4) (ud10?360p3@91.65.248.138) by mail.ud10.udmedia.de with ESMTPSA (ECDHE-RSA-AES256-SHA encrypted, authenticated); 24 Aug 2015 13:44:38 +0200 Date: Mon, 24 Aug 2015 11:52:00 -0000 From: Markus Trippelsdorf To: gcc-patches@gcc.gnu.org Cc: Jason Merrill Subject: [PATCH] Fix c++/67337 (segfault in mangle.c) Message-ID: <20150824114438.GC401@x4> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-SW-Source: 2015-08/txt/msg01403.txt.bz2 decl_mangling_context() in mangle.c returns a NULL_TREE in case of template type parameters. write_template_prefix() needs to handle this situation. Tested on ppc64le. This is a regression from gcc=4.8. OK for trunk, gcc-5 and gcc-4.9? Thanks. PR c++/67337 * mangle.c (write_template_prefix): Guard against context==NULL. diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index 342cb93e68b3..a9993f40b94d 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -1149,7 +1149,7 @@ write_template_prefix (const tree node) So, for the example above, `Outer::Inner' is represented as a substitution candidate by a TREE_LIST whose purpose is `Outer' and whose value is `Outer::Inner'. */ - if (TYPE_P (context)) + if (context && TYPE_P (context)) substitution = build_tree_list (context, templ); else substitution = templ; diff --git a/gcc/testsuite/g++.dg/template/pr67337.C b/gcc/testsuite/g++.dg/template/pr67337.C new file mode 100644 index 000000000000..df2651bc9a57 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/pr67337.C @@ -0,0 +1,25 @@ +template class A +{ + void m_fn1 (int *, int); +}; + +template class B +{ +public: + typedef int Type; +}; + +template class C +{ +public: + C (int); + template