http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59548
Bug ID: 59548
Summary: Abort after copying std::unordered_map in debug mode
Product: gcc
Version: 4.8.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: max at duempel dot org
Created attachment 31471
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31471&action=edit
Demo code
Create an std::unordered_map and save its end() to a variable. Then copy the
std::unordered_map to a temporary variable, and destruct it. Now the iterator
will be "detached", and dereferencing it causes an abort:
/usr/include/c++/4.8/debug/safe_iterator.h:279:error: attempt to
dereference a singular iterator.
Objects involved in the operation:
iterator "this" @ 0x0x7fff741c4f40 {
type =
N11__gnu_debug14_Safe_iteratorINSt8__detail14_Node_iteratorISt4pairIKiiELb0ELb0EEENSt7__debug13unordered_mapIiiSt4hashIiESt8equal_toIiESaIiEEEEE
(mutable iterator);
state = singular;
}
Aborted
Minimal demo code and bug fix attached.
I suggest disabling _Safe_sequence_base's implicit copy constructor to avoid
future bugs like that. Patch attached.