public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "slyfox at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/103769] [11/12 Regression] checking ICE in hashtab_chk_error with alias template and pack expansion after r11-7931
Date: Fri, 07 Jan 2022 09:09:16 +0000	[thread overview]
Message-ID: <bug-103769-4-7BFvl8OP5V@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-103769-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103769

--- Comment #6 from Sergei Trofimovich <slyfox at gcc dot gnu.org> ---
Trying to understand what the error means:

Crash happens when we look up entry in
  gcc/cp/pt.c:static GTY (()) spec_hash_table *type_specializations;

It's a hash table of entries of spec_entry type:
  struct GTY((for_user)) spec_entry
  {
    tree tmpl;  /* The general template this is a specialization of.  */
    tree args;  /* The args for this (maybe-partial) specialization.  */
    tree spec;  /* The specialization itself.  */
  };

spec_hasher type defines both hasher and equality. hash is defined on fields
'tmpl' and 'args', equality is defined on 'tmpl', 'args' and sometimes 'spec':

bool
spec_hasher::equal (spec_entry *e1, spec_entry *e2)
{
  int equal;

  ++comparing_specializations;
  ++comparing_dependent_aliases;
  ++processing_template_decl;
  equal = (e1->tmpl == e2->tmpl
           && comp_template_args (e1->args, e2->args));
  if (equal && flag_concepts
      /* tmpl could be a FIELD_DECL for a capture pack.  */
      && TREE_CODE (e1->tmpl) == TEMPLATE_DECL
      && VAR_P (DECL_TEMPLATE_RESULT (e1->tmpl))
      && uses_template_parms (e1->args))
    {
      /* Partial specializations of a variable template can be distinguished by
         constraints.  */
      tree c1 = e1->spec ? get_constraints (e1->spec) : NULL_TREE;
      tree c2 = e2->spec ? get_constraints (e2->spec) : NULL_TREE;
      equal = equivalent_constraints (c1, c2);
    }
  --processing_template_decl;
  --comparing_dependent_aliases;
  --comparing_specializations;

  return equal;
}

static hashval_t
hash_tmpl_and_args (tree tmpl, tree args)
{
  hashval_t val = iterative_hash_object (DECL_UID (tmpl), 0);
  return iterative_hash_template_arg (args, val);
}

hashval_t
spec_hasher::hash (spec_entry *e)
{
  return hash_tmpl_and_args (e->tmpl, e->args);
}

How can hash differ when values match?

  parent reply	other threads:[~2022-01-07  9:09 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-19 16:39 [Bug c++/103769] New: ICE in hashtab_chk_error alias template and pack expansion ppalka at gcc dot gnu.org
2021-12-19 16:42 ` [Bug c++/103769] [11/12 Regression] checking ICE in hashtab_chk_error with alias template and pack expansion after r11-7931 ppalka at gcc dot gnu.org
2021-12-30 16:13 ` pinskia at gcc dot gnu.org
2021-12-30 16:18 ` pinskia at gcc dot gnu.org
2022-01-01  4:19 ` pinskia at gcc dot gnu.org
2022-01-07  8:05 ` slyfox at gcc dot gnu.org
2022-01-07  9:09 ` slyfox at gcc dot gnu.org [this message]
2022-01-07  9:27 ` marxin at gcc dot gnu.org
2022-01-08 20:02 ` slyfox at gcc dot gnu.org
2022-01-17 12:37 ` rguenth at gcc dot gnu.org
2022-03-23 14:10 ` jason at gcc dot gnu.org
2022-03-28 13:37 ` cvs-commit at gcc dot gnu.org
2022-03-28 19:13 ` [Bug c++/103769] [11 " cvs-commit at gcc dot gnu.org
2022-03-28 19:14 ` jason at gcc dot gnu.org
2022-03-29 19:02 ` alexander.lelyakin at googlemail dot com
2022-11-30  5:27 ` pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-103769-4-7BFvl8OP5V@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).