From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11670 invoked by alias); 10 Feb 2013 21:57:27 -0000 Received: (qmail 11645 invoked by uid 48); 10 Feb 2013 21:57:10 -0000 From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/56267] [4.7/4.8 Regression] unordered containers require Assignable hash function Date: Sun, 10 Feb 2013 21:57:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: redi at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.7.3 X-Bugzilla-Changed-Fields: AssignedTo Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2013-02/txt/msg00992.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56267 Jonathan Wakely changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|unassigned at gcc dot |redi at gcc dot gnu.org |gnu.org | --- Comment #1 from Jonathan Wakely 2013-02-10 21:57:10 UTC --- To be really annoying, a hash function could do this: #include struct hash : std::hash { hash() { throw 1; } hash(int) { } }; int main() { std::unordered_set::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.