EASTL icon indicating copy to clipboard operation
EASTL copied to clipboard

TestArray.cpp:236:70: error: no matching function for call to ‘to_array<long int>(<brace-enclosed initializer list>)’

Open pierretallotte opened this issue 4 years ago • 1 comments

Hi,

I try to compile EASTL but I have an error during the build:

[ 58%] Building CXX object test/CMakeFiles/EASTLTest.dir/source/TestArray.cpp.o
/home/pierre/git/eastl_17/EASTL/test/source/TestArray.cpp: In function ‘int TestArray()’:
/home/pierre/git/eastl_17/EASTL/test/source/TestArray.cpp:236:70: error: no matching function for call to ‘to_array<long int>(<brace-enclosed initializer list>)’
    constexpr auto arr = to_array<long>({0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
                                                                      ^
In file included from /home/pierre/git/eastl_17/EASTL/test/source/TestArray.cpp:7:
/home/pierre/git/eastl_17/EASTL/include/EASTL/array.h:501:54: note: candidate: ‘template<class T, long unsigned int N> constexpr eastl::array<typename eastl::remove_cv<T>::type, N> eastl::to_array(T (&)[N])’
  EA_CONSTEXPR eastl::array<eastl::remove_cv_t<T>, N> to_array(T (&a)[N])
                                                      ^~~~~~~~
/home/pierre/git/eastl_17/EASTL/include/EASTL/array.h:501:54: note:   template argument deduction/substitution failed:
/home/pierre/git/eastl_17/EASTL/test/source/TestArray.cpp:236:70: note:   mismatched types ‘long int’ and ‘int’
    constexpr auto arr = to_array<long>({0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
                                                                      ^
In file included from /home/pierre/git/eastl_17/EASTL/test/source/TestArray.cpp:7:
/home/pierre/git/eastl_17/EASTL/include/EASTL/array.h:509:54: note: candidate: ‘template<class T, long unsigned int N> constexpr eastl::array<typename eastl::remove_cv<T>::type, N> eastl::to_array(T (&&)[N])’
  EA_CONSTEXPR eastl::array<eastl::remove_cv_t<T>, N> to_array(T (&&a)[N])
                                                      ^~~~~~~~
/home/pierre/git/eastl_17/EASTL/include/EASTL/array.h:509:54: note:   template argument deduction/substitution failed:
/home/pierre/git/eastl_17/EASTL/test/source/TestArray.cpp:236:70: note:   mismatched types ‘long int’ and ‘int’
    constexpr auto arr = to_array<long>({0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
                                                                      ^
/home/pierre/git/eastl_17/EASTL/test/source/TestArray.cpp:238:53: error: template argument 1 is invalid
    static_assert(is_same_v<remove_cv_t<decltype(arr)>, eastl::array<long, 10>>, "unexpected return type");
                                                     ^
/home/pierre/git/eastl_17/EASTL/test/source/TestArray.cpp:238:18: error: template argument 1 is invalid
    static_assert(is_same_v<remove_cv_t<decltype(arr)>, eastl::array<long, 10>>, "unexpected return type");
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/pierre/git/eastl_17/EASTL/test/source/TestArray.cpp:253:79: error: no matching function for call to ‘to_array<long unsigned int>(<brace-enclosed initializer list>)’
    constexpr auto arr = to_array<unsigned long>({0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
                                                                               ^
In file included from /home/pierre/git/eastl_17/EASTL/test/source/TestArray.cpp:7:
/home/pierre/git/eastl_17/EASTL/include/EASTL/array.h:501:54: note: candidate: ‘template<class T, long unsigned int N> constexpr eastl::array<typename eastl::remove_cv<T>::type, N> eastl::to_array(T (&)[N])’
  EA_CONSTEXPR eastl::array<eastl::remove_cv_t<T>, N> to_array(T (&a)[N])
                                                      ^~~~~~~~
/home/pierre/git/eastl_17/EASTL/include/EASTL/array.h:501:54: note:   template argument deduction/substitution failed:
/home/pierre/git/eastl_17/EASTL/test/source/TestArray.cpp:253:79: note:   mismatched types ‘long unsigned int’ and ‘int’
    constexpr auto arr = to_array<unsigned long>({0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
                                                                               ^
In file included from /home/pierre/git/eastl_17/EASTL/test/source/TestArray.cpp:7:
/home/pierre/git/eastl_17/EASTL/include/EASTL/array.h:509:54: note: candidate: ‘template<class T, long unsigned int N> constexpr eastl::array<typename eastl::remove_cv<T>::type, N> eastl::to_array(T (&&)[N])’
  EA_CONSTEXPR eastl::array<eastl::remove_cv_t<T>, N> to_array(T (&&a)[N])
                                                      ^~~~~~~~
/home/pierre/git/eastl_17/EASTL/include/EASTL/array.h:509:54: note:   template argument deduction/substitution failed:
/home/pierre/git/eastl_17/EASTL/test/source/TestArray.cpp:253:79: note:   mismatched types ‘long unsigned int’ and ‘int’
    constexpr auto arr = to_array<unsigned long>({0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
                                                                               ^
/home/pierre/git/eastl_17/EASTL/test/source/TestArray.cpp:255:53: error: template argument 1 is invalid
    static_assert(is_same_v<remove_cv_t<decltype(arr)>, eastl::array<unsigned long, 10>>, "unexpected return type");
                                                     ^
/home/pierre/git/eastl_17/EASTL/test/source/TestArray.cpp:255:18: error: template argument 1 is invalid
    static_assert(is_same_v<remove_cv_t<decltype(arr)>, eastl::array<unsigned long, 10>>, "unexpected return type");
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [test/CMakeFiles/EASTLTest.dir/build.make:128: test/CMakeFiles/EASTLTest.dir/source/TestArray.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1134: test/CMakeFiles/EASTLTest.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

I followed the commands given in the contributions page except I enabled the benchmarks:

$ cmake .. -DEASTL_BUILD_TESTS:BOOL=ON -DEASTL_BUILD_BENCHMARK:BOOL=ON
$ cmake --build . --config Release

I'm using GCC with version 8.3.0:

$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 8.3.0-6' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-8 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 8.3.0 (Debian 8.3.0-6)

What can I do to fix this issue?

Thanks.

pierretallotte avatar Nov 26 '20 12:11 pierretallotte

Just in case anyone else runs into this issue - I ran into this issue too (on a different project). It seems to be a problem with the gcc compiler - it doesn't seem to do template argument deduction for class templates properly in v8.x, and it wasn't fixed until 9.x

ljden avatar Nov 28 '22 02:11 ljden