From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 65559 invoked by alias); 14 Dec 2015 08:51:44 -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 65549 invoked by uid 89); 14 Dec 2015 08:51:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-qk0-f171.google.com Received: from mail-qk0-f171.google.com (HELO mail-qk0-f171.google.com) (209.85.220.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 14 Dec 2015 08:51:42 +0000 Received: by qkdp187 with SMTP id p187so125189733qkd.1 for ; Mon, 14 Dec 2015 00:51:40 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.129.70.65 with SMTP id t62mr18036641ywa.240.1450083100157; Mon, 14 Dec 2015 00:51:40 -0800 (PST) Received: by 10.37.195.195 with HTTP; Mon, 14 Dec 2015 00:51:39 -0800 (PST) In-Reply-To: <566B1E93.3010802@redhat.com> References: <5669F6AA.2000606@redhat.com> <566B1E93.3010802@redhat.com> Date: Mon, 14 Dec 2015 08:51:00 -0000 Message-ID: Subject: Re: RFA (hash-*): PATCH for c++/68309 From: Richard Biener To: Jason Merrill Cc: gcc-patches List , Jeffrey A Law , Richard Sandiford , Trevor Saunders Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2015-12/txt/msg01362.txt.bz2 On Fri, Dec 11, 2015 at 8:05 PM, Jason Merrill wrote: > On 12/11/2015 05:10 AM, Richard Biener wrote: >> >> On Thu, Dec 10, 2015 at 11:03 PM, Jason Merrill wrote: >>> >>> The C++ front end uses a temporary hash table to remember specializations >>> of >>> local variables during template instantiations. In a nested function >>> such >>> as a lambda or local class member function, we need to retain the >>> elements >>> from the enclosing function's local_specializations table; otherwise the >>> testcase crashes because we don't find a local specialization for the >>> non-captured use of 'args' in the decltype. >>> >>> This patch addresses that by making a copy of the enclosing >>> local_specializations table if it exists; to enable that I've added copy >>> constructors to hash_table and hash_map. >>> >>> Tested x86_64-pc-linux-gnu. OK for trunk? >> >> >> I don't think you can copy the elements with memcpy they may be C++ >> classes >> that are not copyable. > > > True. Fixed thus: > >> + for (size_t i = 0; i < size; ++i) >> + { >> + value_type &entry = h.m_entries[i]; >> + if (is_deleted (entry)) >> + mark_deleted (m_entries[i]); >> + else if (!is_empty (entry)) >> + m_entries[i] = entry; >> + } > > >> Also watch out for the bool gather_mem_stats = true >> to bool gather_mem_stats = GATHER_STATISTICS change if that crosses your >> change. > > > OK. > >> I also think copying hash tables should be discouraged ;) I wonder if you >> can get around the copying by adding a generation count (to easily >> "backtrack") >> instead. > > > I considered having a chain of tables to check, to handle generations, but I > figured that the tables in question were small enough (only containing local > variables for a single function) that a simple copy was reasonable. Looks good to me now. Needs adjustment to use GATHER_STATISTICS as default-arg for gather_mem_stats now. Thanks, Richard. > Jason >