ecmwf / eckit

A C++ toolkit that supports development of tools and applications at ECMWF.

Home Page:https://confluence.ecmwf.int/display/eckit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compile failure in test_densemap.cc

DJDavies2 opened this issue · comments

[ 66%] Building CXX object tests/container/CMakeFiles/eckit_test_container_densemap.dir/test_densemap.cc.o
In file included from /home/david/src/oops-stuff/eckit/tests/container/test_densemap.cc:14:0:
/home/david/src/oops-stuff/eckit/src/eckit/container/DenseMap.h: In instantiation of ‘class eckit::DenseMap<unsigned int, std::__cxx11::basic_string >’:
/home/david/src/oops-stuff/eckit/tests/container/test_densemap.cc:114:37: required from here
/home/david/src/oops-stuff/eckit/src/eckit/container/DenseMap.h:144:11: error: ‘const V& eckit::DenseMap<K, V>::operator[](const size_t&) const [with K = unsigned int; V = std::cxx11::basic_string; size_t = unsigned int]’ cannot be overloaded
const V& operator[] (const size_t& i ) const { ASSERT(i < values
.size()); return values
[ i ]; }
^~~~~~~~
/home/david/src/oops-stuff/eckit/src/eckit/container/DenseMap.h:141:11: error: with ‘const V& eckit::DenseMap<K, V>::operator[](const K&) const [with K = unsigned int; V = std::_cxx11::basic_string]’
const V& operator[] (const K& k ) const { return values
[ find(k)->idx() ]; }
^~~~~~~~
/home/david/src/oops-stuff/eckit/src/eckit/container/DenseMap.h:145:5: error: ‘V& eckit::DenseMap<K, V>::operator[](const size_t&) [with K = unsigned int; V = std::cxx11::basic_string; size_t = unsigned int]’ cannot be overloaded
V& operator[] (const size_t& i ) { ASSERT(i < keys
.size()); return values
[ i ]; }
^~~~~~~~
/home/david/src/oops-stuff/eckit/src/eckit/container/DenseMap.h:142:5: error: with ‘V& eckit::DenseMap<K, V>::operator[](const K&) [with K = unsigned int; V = std::_cxx11::basic_string]’
V& operator[] (const K& k ) { return values
[ find(k)->idx() ]; }
^~~~~~~~

david@david-System-Product-Name ~/src/oops-stuff $ /home/david/installs/gcc/7.1.0/v1/bin/g++ -v
Using built-in specs.
COLLECT_GCC=/home/david/installs/gcc/7.1.0/v1/bin/g++
COLLECT_LTO_WRAPPER=/home/david/installs/gcc/7.1.0/v1/libexec/gcc/i686-pc-linux-gnu/7.1.0/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: /home/david/src/downloads/gcc-7.1.0/configure --prefix=/home/david/installs/gcc/7.1.0/v1 --enable-languages=all
Thread model: posix
gcc version 7.1.0 (GCC)

david@david-System-Product-Name ~/src/oops-stuff $ uname -a
Linux david-System-Product-Name 3.13.0-149-generic #199-Ubuntu SMP Thu May 17 10:12:57 UTC 2018 i686 athlon i686 GNU/Linux

I think this is because in DenseMap.h the operator[] has overloads for K (from the template) and specifically size_t. test_densemap.cc creates "m" for the test_map_int_string test by passing unsigned in the template for K which it seems is the same type as size_t on this platform. These overloads clash and the compiler cannot resolve them. One fix seems to be to pass "int" instead of "unsigned" in the template for K in test_densemap.cc.