public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/56267] New: [4.7/4.8 Regression] unordered containers require Assignable hash function
@ 2013-02-09 18:50 redi at gcc dot gnu.org
  2013-02-10 12:20 ` [Bug libstdc++/56267] " rguenth at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2013-02-09 18:50 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56267

             Bug #: 56267
           Summary: [4.7/4.8 Regression] unordered containers require
                    Assignable hash function
    Classification: Unclassified
           Product: gcc
           Version: 4.7.3
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: redi@gcc.gnu.org


\x01\x01#include <unordered_set>

struct hash : std::hash<int>
{
  hash& operator=(const hash&) = delete;
};

int main()
{
  std::unordered_set<int, hash> s{ 0, 1, 2 };
  auto i = s.begin(0);
  i = i;
}


The standard does not require hash functions to be assignable.

We must cache the hash code unless is_copy_assignable<H> is true, I'm testing
the fix.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libstdc++/56267] [4.7/4.8 Regression] unordered containers require Assignable hash function
  2013-02-09 18:50 [Bug libstdc++/56267] New: [4.7/4.8 Regression] unordered containers require Assignable hash function redi at gcc dot gnu.org
@ 2013-02-10 12:20 ` rguenth at gcc dot gnu.org
  2013-02-10 21:57 ` redi at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-02-10 12:20 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56267

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.7.3


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libstdc++/56267] [4.7/4.8 Regression] unordered containers require Assignable hash function
  2013-02-09 18:50 [Bug libstdc++/56267] New: [4.7/4.8 Regression] unordered containers require Assignable hash function redi at gcc dot gnu.org
  2013-02-10 12:20 ` [Bug libstdc++/56267] " rguenth at gcc dot gnu.org
@ 2013-02-10 21:57 ` redi at gcc dot gnu.org
  2013-02-10 23:00 ` paolo.carlini at oracle dot com
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2013-02-10 21:57 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56267

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot       |redi at gcc dot gnu.org
                   |gnu.org                     |

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-02-10 21:57:10 UTC ---
To be really annoying, a hash function could do this:

#include <unordered_set>

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

int main()
{
  std::unordered_set<int, hash>::local_iterator i;
}

We can't detect this at compile-time, so it will fail at runtime.

The Hash requirements only include CopyConstructible and Destructible, so we
should not rely on CopyAssignable or DefaultConstructible, so the local
iterator type should really use placement new to copy-construct the hash
function in an aligned_storage buffer, and on assignment destroy it and
copy-construct a new object using placement new again.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libstdc++/56267] [4.7/4.8 Regression] unordered containers require Assignable hash function
  2013-02-09 18:50 [Bug libstdc++/56267] New: [4.7/4.8 Regression] unordered containers require Assignable hash function redi at gcc dot gnu.org
  2013-02-10 12:20 ` [Bug libstdc++/56267] " rguenth at gcc dot gnu.org
  2013-02-10 21:57 ` redi at gcc dot gnu.org
@ 2013-02-10 23:00 ` paolo.carlini at oracle dot com
  2013-02-11  0:20 ` redi at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-02-10 23:00 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56267

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2013-02-10 23:00:34 UTC ---
Thanks Jon for fully handling this. I understand that in principle we could
have checked is_nothrow_default_constructible, but it's of course much better
if we can just use operations guaranteed by the Standard and be done with it.
If you remember, the is_default_constructible check made me a little nervous
from the start...


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libstdc++/56267] [4.7/4.8 Regression] unordered containers require Assignable hash function
  2013-02-09 18:50 [Bug libstdc++/56267] New: [4.7/4.8 Regression] unordered containers require Assignable hash function redi at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2013-02-10 23:00 ` paolo.carlini at oracle dot com
@ 2013-02-11  0:20 ` redi at gcc dot gnu.org
  2013-02-11  0:25 ` redi at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2013-02-11  0:20 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56267

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-02-11 00:19:42 UTC ---
Author: redi
Date: Mon Feb 11 00:19:29 2013
New Revision: 195936

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195936
Log:
    PR libstdc++/56267
    * include/bits/hashtable.h (__cache_default): Check if hash function
    is copy assignable.
    * testsuite/23_containers/unordered_set/56267.cc: New.
    * testsuite/23_containers/unordered_set/instantiation_neg.cc: Adjust
    dg-error line number.
    * testsuite/23_containers/unordered_set/
    not_default_constructible_hash_neg.cc: Likewise.

Added:
    trunk/libstdc++-v3/testsuite/23_containers/unordered_set/56267.cc
      - copied, changed from r195935,
trunk/libstdc++-v3/testsuite/23_containers/unordered_set/instantiation_neg.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/bits/hashtable.h
   
trunk/libstdc++-v3/testsuite/23_containers/unordered_set/instantiation_neg.cc
   
trunk/libstdc++-v3/testsuite/23_containers/unordered_set/not_default_constructible_hash_neg.cc


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libstdc++/56267] [4.7/4.8 Regression] unordered containers require Assignable hash function
  2013-02-09 18:50 [Bug libstdc++/56267] New: [4.7/4.8 Regression] unordered containers require Assignable hash function redi at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2013-02-11  0:20 ` redi at gcc dot gnu.org
@ 2013-02-11  0:25 ` redi at gcc dot gnu.org
  2013-02-14 22:04 ` jsm28 at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2013-02-11  0:25 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56267

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2013-02-11
     Ever Confirmed|0                           |1

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-02-11 00:25:29 UTC ---
The first testcase passes on trunk now, I'm also going to fix that for 4.7.3

Fixing the second testcase will take more work.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libstdc++/56267] [4.7/4.8 Regression] unordered containers require Assignable hash function
  2013-02-09 18:50 [Bug libstdc++/56267] New: [4.7/4.8 Regression] unordered containers require Assignable hash function redi at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2013-02-11  0:25 ` redi at gcc dot gnu.org
@ 2013-02-14 22:04 ` jsm28 at gcc dot gnu.org
  2013-04-11  8:00 ` [Bug libstdc++/56267] [4.7/4.8/4.9 " rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2013-02-14 22:04 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56267

Joseph S. Myers <jsm28 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libstdc++/56267] [4.7/4.8/4.9 Regression] unordered containers require Assignable hash function
  2013-02-09 18:50 [Bug libstdc++/56267] New: [4.7/4.8 Regression] unordered containers require Assignable hash function redi at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2013-02-14 22:04 ` jsm28 at gcc dot gnu.org
@ 2013-04-11  8:00 ` rguenth at gcc dot gnu.org
  2014-01-20 15:50 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-04-11  8:00 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56267

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.7.3                       |4.7.4

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> 2013-04-11 07:59:38 UTC ---
GCC 4.7.3 is being released, adjusting target milestone.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libstdc++/56267] [4.7/4.8/4.9 Regression] unordered containers require Assignable hash function
  2013-02-09 18:50 [Bug libstdc++/56267] New: [4.7/4.8 Regression] unordered containers require Assignable hash function redi at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2013-04-11  8:00 ` [Bug libstdc++/56267] [4.7/4.8/4.9 " rguenth at gcc dot gnu.org
@ 2014-01-20 15:50 ` redi at gcc dot gnu.org
  2014-01-20 18:50 ` redi at gcc dot gnu.org
  2014-01-21 19:39 ` redi at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2014-01-20 15:50 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56267

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Author: redi
Date: Mon Jan 20 15:49:39 2014
New Revision: 206834

URL: http://gcc.gnu.org/viewcvs?rev=206834&root=gcc&view=rev
Log:
    PR libstdc++/56267
    * include/bits/hashtable_policy.h (_Hash_code_base<... false>): Grant
    friendship to _Local_iterator_base<..., false>.
    (_Local_iterator_base): Give protected access to all existing members.
    (_Local_iterator_base::_M_curr()): New public accessor.
    (_Local_iterator_base::_M_get_bucket()): New public accessor.
    (_Local_iterator_base<..., false>::_M_init()): New function to manage
    the lifetime of the _Hash_code_base explicitly.
    (_Local_iterator_base<..., false>::_M_destroy()): Likewise.
    (_Local_iterator_base<..., false>): Define copy constructor and copy
    assignment operator that use new functions to manage _Hash_code_base.
    (operator==(const _Local_iterator_base&, const _Local_iterator_base&),
    operator==(const _Local_iterator_base&, const _Local_iterator_base&)):
    Use public API for _Local_iterator_base.
    * include/debug/safe_local_iterator.h (_Safe_local_iterator): Likewise.
    * include/debug/unordered_map (__debug::unordered_map::erase(),
    __debug::unordered_multimap::erase()): Likewise.
    * include/debug/unordered_set (__debug::unordered_set::erase(),
    __debug::unordered_multiset::erase()): Likewise.
    * testsuite/23_containers/unordered_set/56267-2.cc: New test.

Added:
    trunk/libstdc++-v3/testsuite/23_containers/unordered_set/56267-2.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/bits/hashtable_policy.h
    trunk/libstdc++-v3/include/debug/safe_local_iterator.h
    trunk/libstdc++-v3/include/debug/unordered_map
    trunk/libstdc++-v3/include/debug/unordered_set


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libstdc++/56267] [4.7/4.8/4.9 Regression] unordered containers require Assignable hash function
  2013-02-09 18:50 [Bug libstdc++/56267] New: [4.7/4.8 Regression] unordered containers require Assignable hash function redi at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2014-01-20 15:50 ` redi at gcc dot gnu.org
@ 2014-01-20 18:50 ` redi at gcc dot gnu.org
  2014-01-21 19:39 ` redi at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2014-01-20 18:50 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56267

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|4.7.4                       |4.9.0

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed for 4.9.0, I don't think it's worth backporting to earlier releases


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug libstdc++/56267] [4.7/4.8/4.9 Regression] unordered containers require Assignable hash function
  2013-02-09 18:50 [Bug libstdc++/56267] New: [4.7/4.8 Regression] unordered containers require Assignable hash function redi at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2014-01-20 18:50 ` redi at gcc dot gnu.org
@ 2014-01-21 19:39 ` redi at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: redi at gcc dot gnu.org @ 2014-01-21 19:39 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56267

--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Author: redi
Date: Tue Jan 21 19:38:35 2014
New Revision: 206904

URL: http://gcc.gnu.org/viewcvs?rev=206904&root=gcc&view=rev
Log:
    PR libstdc++/56267
    * include/bits/hashtable.h (__cache_default): Do not depend on
    whether the hash function is DefaultConstructible or CopyAssignable.
    (_Hashtable): Adjust static assertions.
    * doc/xml/manual/containers.xml (containers.unordered.cache): Update.
    * testsuite/23_containers/unordered_set/instantiation_neg.cc: Adjust
    dg-error line number.
    * testsuite/23_containers/unordered_set/
    not_default_constructible_hash_neg.cc: Remove.

Removed:
   
trunk/libstdc++-v3/testsuite/23_containers/unordered_set/not_default_constructible_hash_neg.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/doc/xml/manual/containers.xml
    trunk/libstdc++-v3/include/bits/hashtable.h
   
trunk/libstdc++-v3/testsuite/23_containers/unordered_set/instantiation_neg.cc


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-01-21 19:39 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-09 18:50 [Bug libstdc++/56267] New: [4.7/4.8 Regression] unordered containers require Assignable hash function redi at gcc dot gnu.org
2013-02-10 12:20 ` [Bug libstdc++/56267] " rguenth at gcc dot gnu.org
2013-02-10 21:57 ` redi at gcc dot gnu.org
2013-02-10 23:00 ` paolo.carlini at oracle dot com
2013-02-11  0:20 ` redi at gcc dot gnu.org
2013-02-11  0:25 ` redi at gcc dot gnu.org
2013-02-14 22:04 ` jsm28 at gcc dot gnu.org
2013-04-11  8:00 ` [Bug libstdc++/56267] [4.7/4.8/4.9 " rguenth at gcc dot gnu.org
2014-01-20 15:50 ` redi at gcc dot gnu.org
2014-01-20 18:50 ` redi at gcc dot gnu.org
2014-01-21 19:39 ` redi at gcc dot gnu.org

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).