cxx_generalized_initializers and intel compiler
Dear all,
I tried to use the cxx_std_14 compile time feature. Using the Intel compiler, the cxx_generalized_initializers test fails:
CMake Error in CMakeLists.txt:
The compiler feature "cxx_generalized_initializers" is not known to CXX
compiler
"Intel"
version 17.0.4.20170411.
Debugging this a bit more I tried to compile cxx_generalized_initializers.cpp
with the icpc:
~/tmp/intel$ icpc -std=c++14 -c cxx_generalized_initializers.cpp -Wall -o intel
cxx_generalized_initializers.cpp(30): internal error: assertion failed at: "shared/cfe/edgcpfe/overload.c", line 23806
A<int> as = { 1, 2, 3, 4 };
^
compilation aborted for cxx_generalized_initializers.cpp (code 4)
~/tmp/intel$ icpc --version
icpc (ICC) 18.0.1 20171018
Copyright (C) 1985-2017 Intel Corporation. All rights reserved.
I used a newer Intel compiler. Using g++ together with -Wall
tuned out that:
~/tmp/intel$ g++ -std=c++14 -c cxx_generalized_initializers.cpp -Wall -o g++
cxx_generalized_initializers.cpp: In function 'void someFunc()':
cxx_generalized_initializers.cpp:30:10: warning: variable 'as' set but not used [-Wunused-but-set-variable]
A<int> as = { 1, 2, 3, 4 };
^~
~/tmp/intel$ g++ --version
g++ (GCC) 7.1.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
It might be that g++ does not build as
at all.
However, digging a bit deeper, and changing the declared namespace form std
to std2
(to avoid clashes with std) g+9+ and intel returned:
~/tmp/intel$ g++ -std=c++14 -c cxx_generalized_initializers_std2.cpp -Wall -o g++
cxx_generalized_initializers_std2.cpp: In function 'void someFunc()':
cxx_generalized_initializers_std2.cpp:30:28: error: could not convert '{1, 2, 3, 4}' from '<brace-enclosed initializer list>' to 'A<int>'
A<int> as = { 1, 2, 3, 4 };
~/tmp/intel$ icpc -std=c++14 -c cxx_generalized_initializers_std2.cpp -Wall -o intel
cxx_generalized_initializers_std2.cpp(30): error: no instance of constructor "A<T>::A [with T=int]" matches the argument list
argument types are: (int, int, int, int)
A<int> as = { 1, 2, 3, 4 };
^
cxx_generalized_initializers_std2.cpp(23): note: this candidate was rejected because mismatch in count of arguments
struct A
^
cxx_generalized_initializers_std2.cpp(23): note: this candidate was rejected because mismatch in count of arguments
struct A
^
cxx_generalized_initializers_std2.cpp(25): note: this candidate was rejected because mismatch in count of arguments
A(std2::initializer_list<T>) {}
^
I attached cxx_generalized_initializers_std2.cpp
.
Best,
Andreas