This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ Patch] fix semi-random template specialization ICE
- From: Dodji Seketeli <dodji at seketeli dot org>
- To: Alexandre Oliva <aoliva at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org, Jason Merrill <jason at redhat dot com>
- Date: Thu, 10 May 2012 10:18:02 +0200
- Subject: Re: [C++ Patch] fix semi-random template specialization ICE
- References: <or8vh9yvrg.fsf@livre.localdomain>
Alexandre Oliva <aoliva@redhat.com> a Ãcrit:
[...]
> Anyway, the problem is that, for some unsuitable candidate template
> specializations, tsubst returns error_mark_node, which tsubst_decl
> stores in argvec, and later on register_specialization gets this
> error_mark_node and tries to access it as a tree_vec.
>
> The trivial patch that avoids the misbehavior is returning
> error_mark_node as soon as we get that for argvec. Bootstrapped on
> i686-pc-linux-gnu and x86_64-linux-gnu, regstrapped on the latter.
>
> Ok to install?
FYI, this has been reported as
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53209, so you might add a
reference to that bug in the ChangeLog.
Other than that, I cannot approve or reject this patch, but FWIW, it
looks fine to me.
Let's CC jason.
> for gcc/cp/ChangeLog
> from Alexandre Oliva <aoliva@redhat.com>
>
> * pt.c (tsubst_decl): Bail out if argvec is error_mark_node.
>
> Index: gcc/cp/pt.c
> ===================================================================
> --- gcc/cp/pt.c.orig 2012-04-30 15:34:44.018432544 -0300
> +++ gcc/cp/pt.c 2012-04-30 15:34:47.988375071 -0300
> @@ -10626,6 +10626,8 @@ tsubst_decl (tree t, tree args, tsubst_f
> tmpl = DECL_TI_TEMPLATE (t);
> gen_tmpl = most_general_template (tmpl);
> argvec = tsubst (DECL_TI_ARGS (t), args, complain, in_decl);
> + if (argvec == error_mark_node)
> + RETURN (error_mark_node);
> hash = hash_tmpl_and_args (gen_tmpl, argvec);
> spec = retrieve_specialization (gen_tmpl, argvec, hash);
> }
Thanks.
--
Dodji