On Fri, Dec 11, 2015 at 8:05 PM, Jason Merrill <ja...@redhat.com> wrote:
> On 12/11/2015 05:10 AM, Richard Biener wrote:
>>
>> On Thu, Dec 10, 2015 at 11:03 PM, Jason Merrill <ja...@redhat.com> 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
>

Reply via email to