From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18837 invoked by alias); 30 Oct 2018 10:32:51 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 18279 invoked by uid 89); 30 Oct 2018 10:32:50 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 30 Oct 2018 10:32:49 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id B02F5B014; Tue, 30 Oct 2018 10:32:46 +0000 (UTC) Subject: Re: hash-table violation in gcc/cp/pt.c From: =?UTF-8?Q?Martin_Li=c5=a1ka?= To: gcc-patches@gcc.gnu.org Cc: Nathan Sidwell , Jason Merrill , Jakub Jelinek , Paul Richard Thomas , Martin Jambor , Marek Polacek References: <23ffca95-6492-e609-aebb-bbdd83b5185d@suse.cz> <7ef9e4b3-27db-ff50-2b96-e7ed64dd85cc@suse.cz> Message-ID: Date: Tue, 30 Oct 2018 11:21:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <7ef9e4b3-27db-ff50-2b96-e7ed64dd85cc@suse.cz> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2018-10/txt/msg01891.txt.bz2 On 10/30/18 11:25 AM, Martin Liška wrote: > On 10/29/18 12:04 PM, Martin Liška wrote: >> 3) lookup_template_class_1 >> >> $ ./xg++ -B. /home/marxin/Programming/gcc/gcc/testsuite/g++.dg/template/ttp23.C -c -fchecking=3 >> hash table checking failed: equal operator returns true for a pair of values with a different hash value/home/marxin/Programming/gcc/gcc/testsuite/g++.dg/template/ttp23.C: In instantiation of ‘struct B’: >> /home/marxin/Programming/gcc/gcc/testsuite/g++.dg/template/ttp23.C:15:8: required from here >> /home/marxin/Programming/gcc/gcc/testsuite/g++.dg/template/ttp23.C:8:17: internal compiler error: in find_slot_with_hash, at hash-table.h:905 >> 8 | friend bool foo (const B& a); >> | ^~~ >> 0xa265a4 hash_table::find_slot_with_hash(spec_entry* const&, unsigned int, insert_option) >> /home/marxin/Programming/gcc/gcc/hash-table.h:905 >> 0xa042ce lookup_template_class_1 >> /home/marxin/Programming/gcc/gcc/cp/pt.c:9629 >> 0xa042ce lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*, int, int) >> /home/marxin/Programming/gcc/gcc/cp/pt.c:9674 >> 0xa03670 tsubst_aggr_type >> /home/marxin/Programming/gcc/gcc/cp/pt.c:12679 >> 0x9fefcd tsubst(tree_node*, tree_node*, int, tree_node*) >> /home/marxin/Programming/gcc/gcc/cp/pt.c:14294 >> 0x9fe1a9 tsubst(tree_node*, tree_node*, int, tree_node*) >> /home/marxin/Programming/gcc/gcc/cp/pt.c:14285 >> 0xa0d8bd tsubst_arg_types >> /home/marxin/Programming/gcc/gcc/cp/pt.c:13891 >> 0xa0dc24 tsubst_function_type >> /home/marxin/Programming/gcc/gcc/cp/pt.c:14032 >> 0x9fe790 tsubst(tree_node*, tree_node*, int, tree_node*) >> /home/marxin/Programming/gcc/gcc/cp/pt.c:14769 >> 0x9f2c7c tsubst_function_decl >> /home/marxin/Programming/gcc/gcc/cp/pt.c:12921 >> 0xa02d27 tsubst_template_decl >> /home/marxin/Programming/gcc/gcc/cp/pt.c:13214 >> 0x9f4416 tsubst_decl >> /home/marxin/Programming/gcc/gcc/cp/pt.c:13316 >> 0x9ff0ca tsubst(tree_node*, tree_node*, int, tree_node*) >> /home/marxin/Programming/gcc/gcc/cp/pt.c:14212 >> 0xa1dfd0 tsubst_friend_function >> /home/marxin/Programming/gcc/gcc/cp/pt.c:10310 >> 0xa1dfd0 instantiate_class_template_1 >> /home/marxin/Programming/gcc/gcc/cp/pt.c:11359 >> 0xa1dfd0 instantiate_class_template(tree_node*) >> /home/marxin/Programming/gcc/gcc/cp/pt.c:11424 >> 0xa66b22 complete_type(tree_node*) >> /home/marxin/Programming/gcc/gcc/cp/typeck.c:138 >> 0x9023c7 start_decl_1(tree_node*, bool) >> /home/marxin/Programming/gcc/gcc/cp/decl.c:5278 >> 0x92a15f start_decl(cp_declarator const*, cp_decl_specifier_seq*, int, tree_node*, tree_node*, tree_node**) >> /home/marxin/Programming/gcc/gcc/cp/decl.c:5241 >> 0x9c1944 cp_parser_init_declarator >> /home/marxin/Programming/gcc/gcc/cp/parser.c:19750 > > This one is about inconsistency between: > > /* Returns a hash for a template TMPL and template arguments ARGS. */ > > 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); > } > > iterative_hash_template_arg is problematic, differs from: > bool > spec_hasher::equal (spec_entry *e1, spec_entry *e2) > { > int equal; > > ++comparing_specializations; > equal = (e1->tmpl == e2->tmpl > && comp_template_args (e1->args, e2->args)); > ... > > where comp_template_args (e1->args, e2->args) returns true, but > iterative_hash_template_arg values are different. > > Can please some C++ maintainer take a look? > > Thanks, > Martin > The same spec_hasher type is also involved in 4) 0xa265a4 hash_table::find_slot_with_hash(spec_entry* const&, unsigned int, insert_option) /home/marxin/Programming/gcc/gcc/hash-table.h:905 0x9e35e6 register_specialization /home/marxin/Programming/gcc/gcc/cp/pt.c:1534 0xa22ac3 check_explicit_specialization(tree_node*, tree_node*, int, int, tree_node*) /home/marxin/Programming/gcc/gcc/cp/pt.c:3243 0x91552d grokfndecl /home/marxin/Programming/gcc/gcc/cp/decl.c:9106 ... Martin