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

C++11 and <vector> error

Michael_M_13
Beginner
901 Views

I'm having trouble including vectors while compiling with -std=c++11. If I try to compile

[cpp]#include <vector>

int main()
{
return 0;
}[/cpp]

using icpc -std=c++11 vector_test.cpp, I get the following error:

/opt/local/include/gcc48/c++/bits/alloc_traits.h(555): error: invalid type for defaulted assignment operator
__allow_copy_cons& operator=(__allow_copy_cons&&) = default;

It compiles fine under gcc 4.8. Is this a problem with icpc or with my library files?

Thanks

0 Kudos
9 Replies
SergeyKostrov
Valued Contributor II
901 Views
>>...It compiles fine under gcc 4.8. Is this a problem with icpc or with my library files? If the test case was successfully compiled with GCC version 4.8 then it is clear that there is a problem with ICPC.
0 Kudos
TimP
Honored Contributor III
901 Views

I don't see any such problem with current icpc.  Perhaps OP used a version of icpc which was too old to work with g++ 4.8.

0 Kudos
Michael_M_13
Beginner
901 Views

I updated to the latest version of icpc when I encountered the problem; I'm currently using 13.0.3. The problem also exists using g++ 4.7 (both versions of gcc are installed via MacPorts, incidentally, and both just updated). If I switch to (MacPorts) g++ 4.5 or the Apple g++ 4.2, then that empty test code compiles fine, but if I try to declare a vector using an initializer list, it fails with the error

error: no instance of constructor "std::vector<_Tp, _Alloc>::vector [with _Tp=double, _Alloc=std::allocator<double>]" matches the argument list
argument types are: (double, double, double)
std::vector<double> testvec = {1.0, 2.0, 3.0};

0 Kudos
SergeyKostrov
Valued Contributor II
902 Views
>>If I switch to (MacPorts) g++ 4.5 or the Apple g++ 4.2, then that empty test code compiles fine, but if I try to declare >>a vector using an initializer list, it fails with the error >> >>error: no instance of constructor "std::vector<_Tp, _Alloc>::vector [with _Tp=double, _Alloc=std::allocator]" >>matches the argument list >>argument types are: (double, double, double) >>std::vector testvec = {1.0, 2.0, 3.0}; Why wouldn't you upload vector header file for review? If g++ 4.5, g++ 4.2 and icpc are failing to compile that test project you have some issue with STL headers.
0 Kudos
Michael_M_13
Beginner
902 Views

I hadn't attached the headers initially since they're part of gcc, gcc doesn't complain about them, and I haven't modified them. I'm attaching the vector and alloc_traits (where the complier error occurred) headers for gcc 4.8.

0 Kudos
SergeyKostrov
Valued Contributor II
902 Views
This is original version ( I've bolded where the compiler fails / line 555 ): ... // Used to delete copy constructor of unordered containers template<> struct __allow_copy_cons { __allow_copy_cons() = default; __allow_copy_cons(const __allow_copy_cons&) = delete; __allow_copy_cons(__allow_copy_cons&&) = default; __allow_copy_cons& operator=(const __allow_copy_cons&) = default; __allow_copy_cons& operator=(__allow_copy_cons&&) = default; }; ... Could you try the following version? ... // Used to delete copy constructor of unordered containers template<> struct __allow_copy_cons { __allow_copy_cons() = default; __allow_copy_cons(const __allow_copy_cons&) = delete; __allow_copy_cons(__allow_copy_cons&&) = default; __allow_copy_cons& operator=(const __allow_copy_cons&) = default; __allow_copy_cons& operator=(const __allow_copy_cons&&) = default; }; ... Note: I've added const specificator.
0 Kudos
Amanda_S_Intel
Employee
902 Views

Like Tim, I am unable to reproduce any problems compiling with your icc version as well newwer versions. Could something be awry in your environment?

0 Kudos
Casey
Beginner
902 Views

I am also unable to reproduce problems.  Running icc version 13.1.3 (gcc version 4.6.3 compatibility) on Linux.  

0 Kudos
asd__asdqwe
Beginner
902 Views

nvm

0 Kudos
Reply