skarupke / flat_hash_map

A very fast hashtable
1.69k stars 186 forks source link

Bug: Fails to compile when size_t is not the same size as unsigned long long #40

Open ZigaSajovic opened 3 years ago

ZigaSajovic commented 3 years ago

In the implementation size_t is used. But the implementation of flat_maprequires this type to be the same size as unsigned long long. But this is not true on all platforms (e.g. emscripten). Hence, when compiling one gets a hard-error for narrowing conversions from unsigned long long to <unsigned type of smaller size>. The bug is easily fixed by defining

using ska::size_t = unsigned long long

And replacing the size_t with ska::size_t in the implementation.

Also note that when size_t is of size 4 one gets a warning for overflow in some expressions.