diff options
author | Ian Lance Taylor <iant@google.com> | 2011-05-25 23:09:14 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-05-25 23:09:14 +0000 |
commit | 2b4e07b814b50a6f5cdf6b10d05117623d8854c9 (patch) | |
tree | c4e6283a51cca060e1f1e57da5f033aa3fced142 /libstdc++-v3/testsuite/backward | |
parent | 48126bcbc276e1684f96f7c087d69688028cae73 (diff) | |
download | gcc-2b4e07b814b50a6f5cdf6b10d05117623d8854c9.zip gcc-2b4e07b814b50a6f5cdf6b10d05117623d8854c9.tar.gz gcc-2b4e07b814b50a6f5cdf6b10d05117623d8854c9.tar.bz2 |
re PR libstdc++/49060 (use of deleted memory in __gnu_cxx::hashtable::erase)
PR libstdc++/49060
* include/backward/hashtable.h (hashtable::erase): Don't crash if
erasing first and another element with a reference to the other
element.
* testsuite/backward/hash_set/49060.cc: New.
From-SVN: r174240
Diffstat (limited to 'libstdc++-v3/testsuite/backward')
-rw-r--r-- | libstdc++-v3/testsuite/backward/hash_set/49060.cc | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/backward/hash_set/49060.cc b/libstdc++-v3/testsuite/backward/hash_set/49060.cc new file mode 100644 index 0000000..985cfcf --- /dev/null +++ b/libstdc++-v3/testsuite/backward/hash_set/49060.cc @@ -0,0 +1,35 @@ +// { dg-options "-Wno-deprecated" } + +#include <backward/hashtable.h> +#include <utility> + +struct modulo2_hash +{ + size_t operator()(int const key) const + { + return key % 2; + } +}; + +struct modulo2_eq +{ + bool operator()(int const left, int const right) const + { + return left % 2 == right % 2; + } +}; + +int main() +{ + typedef std::_Select1st<std::pair<int const, int> > extract_type; + typedef + __gnu_cxx::hashtable<std::pair<int const, int>, int, modulo2_hash, + extract_type, modulo2_eq, std::allocator<int> > + table_type; + table_type table(4, modulo2_hash(), modulo2_eq(), extract_type(), + std::allocator<int>()); + + table.insert_equal(std::make_pair(2, 1)); + table_type::iterator it(table.insert_equal(std::make_pair(4, 2))); + table.erase(it->first); +} |