Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

icc (16.0.1) w/ gcc 4.8.3 compatibility cannot compile std::unorded_map with custom hash

Andrea_D_1
Beginner
594 Views

Hello,

icc version 16.0.1 w/ gcc 4.8.3 compatibility:

cpc -v -E -x c++ - < /dev/null |& head -n1
icpc version 16.0.1 (gcc version 4.8.3 compatibility)

cannot compile the following snippet of code (simplification of a more complex code):

#include <unordered_map>

using key=const int;//std::pair<const int*,const int*>;

struct Myhash {
        Myhash() = default;
        std::hash<int> hash_int_t;
        inline size_t operator()(const key& x) const throw() {
                return hash_int_t(x);
        }
};

std::unordered_map<key,int,Myhash> mm;

emitting the following error (the problem is in the hash_int_t variable):

icpc -std=c++11 -c unordered_map.cc
/opt/gcc-4.8.3/include/c++/4.8.3/bits/hashtable.h(268): error: static assertion failed with "Cache the hash code or make functors involved in hash code and bucket index computation default constructible"
        static_assert(__if_hash_not_cached<
        ^
[...omissis...]

The same snippet of code can be compiled by icc with gcc 4.9 compatibility layer.

Is this a known bug/issue?

Thank you,

Andrea Dotti

0 Kudos
2 Replies
Kittur_G_Intel
Employee
594 Views

Hi Andrea,
Yes, you're correct it compiles fine with  gcc4.9. Let me look into this and update you accordingly, thx

Regards,
Kittur

0 Kudos
Kittur_G_Intel
Employee
594 Views

Hi Andrea,
Yes this is  bug in the compiler and I've filed an issue with our developers (DPD200410621) and will  update you as soon as the release with the fix is out. Appreciate your patience till then.
Regards,
Kittur

0 Kudos
Reply