alekseyd / sparsehash

Automatically exported from code.google.com/p/sparsehash
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Assertion `use_empty' failed. #28

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Using sparsehash 1.4 on Ubuntu 8.10 64-bit:

yang@yang-xps410 ~/sandbox/cc
$ uname -a
Linux yang-xps410 2.6.27-11-generic #1 SMP Thu Jan 29 19:28:32 UTC 2009
x86_64 GNU/Linux

yang@yang-xps410 ~/sandbox/cc
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 8.10
Release:        8.10
Codename:       intrepid

yang@yang-xps410 ~/sandbox/cc
$ cat google_sparsehash.cc
#include <google/dense_hash_map>
using namespace google;
int main() {
  dense_hash_map<int,int> m;
  m[1] = 2; // failure happens only when this line is present.
  return 0;
}

yang@yang-xps410 ~/sandbox/cc
$ g++ -Wall -g3 -o google_sparsehash google_sparsehash.cc -Wextra
-Wconversion -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings
-Winit-self -Wno-unused-parameter -Wparentheses -Wmissing-format-attribute
-Wfloat-equal -Winline -Woverloaded-virtual -Wsign-promo -Wc++0x-compat -Wsynth

yang@yang-xps410 ~/sandbox/cc
$ ./google_sparsehash
google_sparsehash:
/usr/local/include/google/sparsehash/densehashtable.h:375: bool
google::dense_hashtable<Value, Key, HashFcn, ExtractKey, EqualKey,
Alloc>::test_empty(size_t) const [with Value = std::pair<const int, int>,
Key = int, HashFcn = __gnu_cxx::hash<int>, ExtractKey =
google::dense_hash_map<int, int, __gnu_cxx::hash<int>, std::equal_to<int>,
std::allocator<int> >::SelectKey, EqualKey = std::equal_to<int>, Alloc =
std::allocator<int>]: Assertion `use_empty' failed.
Aborted

Original issue reported on code.google.com by yanghate...@gmail.com on 14 Feb 2009 at 8:54

GoogleCodeExporter commented 9 years ago
I was also able to repro this on a 32-bit Ubuntu 8.10.

Anyway, just wondering if I'm incorrectly using the map or if this is a bug.

Original comment by yanghate...@gmail.com on 14 Feb 2009 at 8:55

GoogleCodeExporter commented 9 years ago
You need to call set_empty_key() near the beginning of your program.  See
doc/dense_hash_map.html and also the all-caps comments at the top of
dense_hash_map:

http://code.google.com/p/google-sparsehash/source/browse/trunk/src/google/dense_
hash_map

Original comment by csilv...@gmail.com on 17 Feb 2009 at 1:30