* [patch] fix libstdc++/56278
@ 2013-02-11 0:21 Jonathan Wakely
[not found] ` <511AABED.3050805@gmail.com>
0 siblings, 1 reply; 2+ messages in thread
From: Jonathan Wakely @ 2013-02-11 0:21 UTC (permalink / raw)
To: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 234 bytes --]
PR libstdc++/56278
* include/bits/hashtable_policy.h (_Hash_code_base): Make default
constructor public.
* testsuite/23_containers/unordered_set/56278.cc: New.
Tested x86_64-linux, committed to trunk.
[-- Attachment #2: patch-56278.txt --]
[-- Type: text/plain, Size: 3315 bytes --]
commit b893384109ddb4dfc1afac24dc6b2c56557f2fa8
Author: Jonathan Wakely <jwakely.gcc@gmail.com>
Date: Sun Feb 10 22:08:34 2013 +0000
PR libstdc++/56278
* include/bits/hashtable_policy.h (_Hash_code_base): Make default
constructor public.
* testsuite/23_containers/unordered_set/56278.cc: New.
diff --git a/libstdc++-v3/include/bits/hashtable_policy.h b/libstdc++-v3/include/bits/hashtable_policy.h
index f4d8dc0..a88b32e 100644
--- a/libstdc++-v3/include/bits/hashtable_policy.h
+++ b/libstdc++-v3/include/bits/hashtable_policy.h
@@ -918,13 +918,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
using __ebo_extract_key = _Hashtable_ebo_helper<0, _ExtractKey>;
using __ebo_hash = _Hashtable_ebo_helper<1, _Hash>;
+ public:
+ // We need the default constructor for the local iterators.
+ _Hash_code_base() = default;
+
protected:
typedef void* __hash_code;
typedef _Hash_node<_Value, false> __node_type;
- // We need the default constructor for the local iterators.
- _Hash_code_base() = default;
-
+ protected:
_Hash_code_base(const _ExtractKey& __ex, const _H1&, const _H2&,
const _Hash& __h)
: __ebo_extract_key(__ex), __ebo_hash(__h) { }
@@ -956,7 +958,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
std::swap(_M_ranged_hash(), __x._M_ranged_hash());
}
- protected:
const _ExtractKey&
_M_extract() const { return __ebo_extract_key::_S_cget(*this); }
@@ -1003,13 +1004,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
hash_function() const
{ return _M_h1(); }
+ // We need the default constructor for the local iterators.
+ _Hash_code_base() = default;
+
protected:
typedef std::size_t __hash_code;
typedef _Hash_node<_Value, false> __node_type;
- // We need the default constructor for the local iterators.
- _Hash_code_base() = default;
-
_Hash_code_base(const _ExtractKey& __ex,
const _H1& __h1, const _H2& __h2,
const _Default_ranged_hash&)
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/56278.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/56278.cc
new file mode 100644
index 0000000..c73a524
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/unordered_set/56278.cc
@@ -0,0 +1,30 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// Copyright (C) 2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// libstdc++/56278
+
+#include <unordered_set>
+
+struct hash : std::hash<int>
+{
+ hash() { }
+};
+
+std::unordered_set<int, hash>::local_iterator i;
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [patch] fix libstdc++/56278
[not found] ` <CAH6eHdSf+6494F=sXs3C5eqOVZnspRDg6V3cn6RDRs_aZERggg@mail.gmail.com>
@ 2013-02-13 21:11 ` François Dumont
0 siblings, 0 replies; 2+ messages in thread
From: François Dumont @ 2013-02-13 21:11 UTC (permalink / raw)
To: Jonathan Wakely; +Cc: Paolo Carlini, libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 1161 bytes --]
Committed then.
2013-02-13 François Dumont <fdumont@gcc.gnu.org>
* include/bits/hashtable_policy.h (_Hash_code_base): Restore
default constructor protected.
* include/bits/hashtable.h: static assert that _Hash_code_base has
a default constructor available through inheritance.
On 02/13/2013 12:36 PM, Jonathan Wakely wrote:
> On 13 February 2013 10:19, Paolo Carlini wrote:
>> On 02/12/2013 09:54 PM, François Dumont wrote:
>>> Of course this is not mandatory but I think _Hash_code_base would be
>>> cleaner this way only exposing as public what is required by C++11. It can
>>> also wait for 4.9.
>> I like it. Thanks Francois. If Jon has no objections over the next day or
>> so, please go ahead.
> No objection, I agree it's suitable for 4.8 as it's refining my
> regression fix, but I don't think it really makes any difference.
> There is nothing required by C++11 for _Hash_code_base's constructors
> because it's an implementation detail, and the only way a user can
> tell the difference between a public and protected constructor is
> trying to construct _Hash_code_base directly, which is obviously
> unsupported.
>
[-- Attachment #2: hash_code_base.patch --]
[-- Type: text/x-patch, Size: 2174 bytes --]
Index: include/bits/hashtable_policy.h
===================================================================
--- include/bits/hashtable_policy.h (revision 195955)
+++ include/bits/hashtable_policy.h (working copy)
@@ -918,15 +918,13 @@
using __ebo_extract_key = _Hashtable_ebo_helper<0, _ExtractKey>;
using __ebo_hash = _Hashtable_ebo_helper<1, _Hash>;
- public:
- // We need the default constructor for the local iterators.
- _Hash_code_base() = default;
-
protected:
typedef void* __hash_code;
typedef _Hash_node<_Value, false> __node_type;
- protected:
+ // We need the default constructor for the local iterators.
+ _Hash_code_base() = default;
+
_Hash_code_base(const _ExtractKey& __ex, const _H1&, const _H2&,
const _Hash& __h)
: __ebo_extract_key(__ex), __ebo_hash(__h) { }
@@ -1004,13 +1002,13 @@
hash_function() const
{ return _M_h1(); }
- // We need the default constructor for the local iterators.
- _Hash_code_base() = default;
-
protected:
typedef std::size_t __hash_code;
typedef _Hash_node<_Value, false> __node_type;
+ // We need the default constructor for the local iterators.
+ _Hash_code_base() = default;
+
_Hash_code_base(const _ExtractKey& __ex,
const _H1& __h1, const _H2& __h2,
const _Default_ranged_hash&)
Index: include/bits/hashtable.h
===================================================================
--- include/bits/hashtable.h (revision 195955)
+++ include/bits/hashtable.h (working copy)
@@ -266,7 +266,10 @@
// __hash_code_base above to compute node bucket index so it has to be
// default constructible.
static_assert(__if_hash_not_cached<
- is_default_constructible<__hash_code_base>>::value,
+ is_default_constructible<
+ // We use _Hashtable_ebo_helper to access the protected
+ // default constructor.
+ __detail::_Hashtable_ebo_helper<0, __hash_code_base>>>::value,
"Cache the hash code or make functors involved in hash code"
" and bucket index computation default constructible");
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-02-13 21:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-11 0:21 [patch] fix libstdc++/56278 Jonathan Wakely
[not found] ` <511AABED.3050805@gmail.com>
[not found] ` <511B68AB.7070307@oracle.com>
[not found] ` <CAH6eHdSf+6494F=sXs3C5eqOVZnspRDg6V3cn6RDRs_aZERggg@mail.gmail.com>
2013-02-13 21:11 ` François Dumont
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).