Bug 56278 - [4.8 Regression] unordered containers fail static assertion
Summary: [4.8 Regression] unordered containers fail static assertion
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: 4.8.0
Assignee: Jonathan Wakely
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2013-02-10 21:55 UTC by Jonathan Wakely
Modified: 2013-02-11 00:21 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-02-11 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Wakely 2013-02-10 21:55:04 UTC
#include <unordered_set>

struct hash : std::hash<int>
{
  hash() { }
};

std::unordered_set<int, hash>::local_iterator i;


In file included from /home/jwakely/gcc/4.x/include/c++/4.8.0/unordered_set:47:0,
                 from h.cc:1:
/home/jwakely/gcc/4.x/include/c++/4.8.0/bits/hashtable.h: In instantiation of ‘class std::_Hashtable<int, int, std::allocator<int>, std::__detail::_Identity, std::equal_to<int>, hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, true, true> >’:
/home/jwakely/gcc/4.x/include/c++/4.8.0/bits/unordered_set.h:96:18:   required from ‘class std::unordered_set<int, hash>’
h.cc:9:30:   required from here
/home/jwakely/gcc/4.x/include/c++/4.8.0/bits/hashtable.h:267:7: error: static assertion failed: Cache the hash code or make functors involved in hash code and bucket index computation default constructible
       static_assert(__if_hash_not_cached<
       ^

I think the problem is that the default constructor of _Hash_code_base is not public, so checking is_default_constructible fails.
Comment 1 Jonathan Wakely 2013-02-11 00:19:25 UTC
Author: redi
Date: Mon Feb 11 00:19:14 2013
New Revision: 195935

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195935
Log:
	PR libstdc++/56278
	* include/bits/hashtable_policy.h (_Hash_code_base): Make default
	constructor public.
	* testsuite/23_containers/unordered_set/56278.cc: New.

Added:
    trunk/libstdc++-v3/testsuite/23_containers/unordered_set/56278.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/bits/hashtable_policy.h
Comment 2 Jonathan Wakely 2013-02-11 00:21:13 UTC
fixed