This simple program
#include <vector>
int main()
{
using int3 = int[3];
std::vector<int3> vec( 2 );
}
does not compile in the latest Visual Studio 2019 16.10.0 with stdcpplatest
switch, producing the error:
>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\xutility(144,1): error C2440: 'return': cannot convert from 'int *' to '_Ty (*)'
1> with
1> [
1> _Ty=int [3]
1> ]
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\xutility(144,48): message : Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\xmemory(707): message : see reference to function template instantiation '_Ty (*std::construct_at<_Objty,,void>(_Ty (*const )) noexcept)[3]' being compiled
1> with
1> [
1> _Ty=int [3],
1> _Objty=int [3]
1> ]
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\xmemory(1610): message : see reference to function template instantiation 'void std::_Default_allocator_traits<_Alloc>::construct<_Ty,>(_Alloc &,_Objty (*const ))' being compiled
1> with
1> [
1> _Alloc=std::allocator<int3>,
1> _Ty=int [3],
1> _Objty=int [3]
1> ]
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\xmemory(1611): message : see reference to function template instantiation 'void std::_Default_allocator_traits<_Alloc>::construct<_Ty,>(_Alloc &,_Objty (*const ))' being compiled
1> with
1> [
1> _Alloc=std::allocator<int3>,
1> _Ty=int [3],
1> _Objty=int [3]
1> ]
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\xmemory(1811): message : see reference to function template instantiation 'void std::_Uninitialized_backout_al<_Alloc>::_Emplace_back<>(void)' being compiled
1> with
1> [
1> _Alloc=std::allocator<int3>
1> ]
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\xmemory(1811): message : see reference to function template instantiation 'void std::_Uninitialized_backout_al<_Alloc>::_Emplace_back<>(void)' being compiled
1> with
1> [
1> _Alloc=std::allocator<int3>
1> ]
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\vector(1648): message : see reference to function template instantiation 'int (*std::_Uninitialized_value_construct_n<std::allocator<int3>>(int (*)[3],unsigned __int64,_Alloc &))[3]' being compiled
1> with
1> [
1> _Alloc=std::allocator<int3>
1> ]
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\vector(1646): message : while compiling class template member function 'int (*std::vector<int3,std::allocator<int3>>::_Ufill(int (*)[3],const unsigned __int64,std::_Value_init_tag))[3]'
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\include\vector(493): message : see reference to function template instantiation 'int (*std::vector<int3,std::allocator<int3>>::_Ufill(int (*)[3],const unsigned __int64,std::_Value_init_tag))[3]' being compiled
1>Test.cpp(271): message : see reference to class template instantiation 'std::vector<int3,std::allocator<int3>>' being compiled
1>Done building project "Project1.vcxproj" -- FAILED.
The program compiled fine in the previous version of Visual Studio 2019 16.9.5, as well as in gcc 11, but fails to compile in clang 5 as well. Is std::vector of array permitted by the standard or is it an implementation specific behavior?