On 7/12/24 4:42 PM, Seyed Sajad Kahani wrote:
This patch addresses a difference between the hash function and the equality
function for canonical types of template parameters (ctp_hasher). The equality
function uses comptypes (typeck.cc) (with COMPARE_STRUCTURAL) and checks
constraint equality for two auto nodes (typeck.cc:1586), while the hash
function ignores it (pt.cc:4528). This leads to hash collisions that can be
avoided by using `hash_placeholder_constraint` (constraint.cc:1150).

The change looks good, just a couple of whitespace tweaks needed. But what happened to the testcase?

--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -4525,7 +4525,12 @@ struct ctp_hasher : ggc_ptr_hash<tree_node>
      val = iterative_hash_object (TEMPLATE_TYPE_LEVEL (t), val);
      val = iterative_hash_object (TEMPLATE_TYPE_IDX (t), val);
      if (TREE_CODE (t) == TEMPLATE_TYPE_PARM)
-      val = iterative_hash_template_arg (CLASS_PLACEHOLDER_TEMPLATE (t), val);
+      {
+       val

Extra space at end of line.

+         = iterative_hash_template_arg (CLASS_PLACEHOLDER_TEMPLATE (t), val);
+       if (tree c = NON_ERROR (PLACEHOLDER_TYPE_CONSTRAINTS (t)))
+         val = iterative_hash_placeholder_constraint(c, val);

Missing space before paren.

Jason

Reply via email to