I've had no luck in reducing the testcase in this PR, creduce won't get even past the initial passes, and reducing by hand didn't get me very far, either.
But the problem seems to be merely that we're not handling USING_DECLs in cp_tree_equal, and we can get there via comp_template_arguments. In this case we have two USING_DECLs with different full names. So this patch just adds the USING_DECL case, similarly to e.g. https://gcc.gnu.org/ml/gcc-patches/2012-10/msg00799.html Bootstrapped/regtested on x86_64-linux, ok for trunk/8? I verified manually that this fixes the testcase from the PR. 2018-06-04 Marek Polacek <pola...@redhat.com> PR c++/85976 * tree.c (cp_tree_equal): Handle USING_DECL. --- gcc/cp/tree.c +++ gcc/cp/tree.c @@ -3752,6 +3752,7 @@ cp_tree_equal (tree t1, tree t2) case TEMPLATE_DECL: case IDENTIFIER_NODE: case SSA_NAME: + case USING_DECL: return false; case BASELINK: Marek