Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.
7679 Discussions

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

Andrea_D_1
Beginner
337 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
337 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

Kittur_G_Intel
Employee
337 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

Reply