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: Martin Jambor <mjambor at suse dot cz>
- To: Alexandre Oliva <aoliva at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 4 May 2012 13:48:28 +0200
- Subject: Re: [C++ Patch] fix semi-random template specialization ICE
- References: <or8vh9yvrg.fsf@livre.localdomain>
Hi,
On Thu, May 03, 2012 at 03:17:23PM -0300, Alexandre Oliva wrote:
> I've recently started getting âlibstdc++-v3/include/functional:2057:63:
> internal compiler error: tree check: expected tree_vec, have error_mark
> in comp_template_args_with_info, at cp/pt.c:7038â on i686-linux-gnu,
> building libstdc++-v3/src/c++11/functexcept.cc -fPIC, at stage1 and on
> non-bootstrapped builds. The problem would not occur on
> x86_64-linux-gnu with the -m32 multilib.
I suppose this is PR 53209.
Thanks for dealing with this!
Martin
>
> Jakub reported getting similar errors in the testsuite, but not in the
> libstdc++-v3 build.
>
> Bisection revealted the patch that exposed the latent error was r186948,
> but I gather it only introduced more potentially-failing specializations
> in libstdc++-v3 at spots that wouldn't trigger the bug before.
>
> I couldn't pinpoint the exact source of randomness that causes the build
> to fail at precisely the same point on a given machine at a certain
> stage, but not on others. What I do know is that it occurs while
> iterating on a hash table, which, depending on how the hash is computed,
> may explain why we visit some nodes before others depending on
> environmentally-deterministic causes.
>
> 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?
>
> 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);
> }
>
>
> --
> Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/
> You must be the change you wish to see in the world. -- Gandhi
> Be Free! -- http://FSFLA.org/ FSF Latin America board member
> Free Software Evangelist Red Hat Brazil Compiler Engineer