为什么 Coliru 的 Clang 无法编译 vector::push_back?
Why Clang at Coliru can't compile vector::push_back?
See it here.
程序很平凡,像这样:
#include <vector>
std::vector<int> bombs;
int main()
{
bombs.push_back(42); // compile errors
}
诊断对我来说意义不大:
In file included from main.cpp:1:
In file included from
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/8.1.0/../../../../include/c++/8.1.0/vector:60:
In file included from
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/8.1.0/../../../../include/c++/8.1.0/bits/stl_algobase.h:64:
In file included from
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/8.1.0/../../../../include/c++/8.1.0/bits/stl_pair.h:59:
In file included from
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/8.1.0/../../../../include/c++/8.1.0/bits/move.h:55:
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/8.1.0/../../../../include/c++/8.1.0/type_traits:1061:48: error: '_Tp' does not refer to a value
: public __bool_constant<__is_assignable(_Tp, _Up)>
^
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/8.1.0/../../../../include/c++/8.1.0/type_traits:1059:21: note: declared here
template<typename _Tp, typename _Up>
^
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/8.1.0/../../../../include/c++/8.1.0/type_traits:1061:53: error: _Up
does not refer to a value
: public __bool_constant<__is_assignable(_Tp, _Up)>
^
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/8.1.0/../../../../include/c++/8.1.0/type_traits:1059:35: note: declared here
template<typename _Tp, typename _Up>
^
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/8.1.0/../../../../include/c++/8.1.0/type_traits:1062:5:
error: expected class name
{ };
^
In file included from main.cpp:1:
In file included from
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/8.1.0/../../../../include/c++/8.1.0/vector:63:
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/8.1.0/../../../../include/c++/8.1.0/bits/stl_uninitialized.h:128:70:
error: no member named value
in std::is_assignable<int &, int &&>
const bool __assignable = is_assignable<_RefType2, _RefType1>::value;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/8.1.0/../../../../include/c++/8.1.0/bits/stl_uninitialized.h:289:19:
note: in instantiation of function template specialization
std::uninitialized_copy<std::move_iterator<int *>, int *>
requested
here
{ return std::uninitialized_copy(__first, __last, __result); }
^
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/8.1.0/../../../../include/c++/8.1.0/bits/stl_uninitialized.h:310:19:
note: in instantiation of function template specialization
std::__uninitialized_copy_a<std::move_iterator<int *>, int *, int>
requested here
return std::__uninitialized_copy_a
^
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/8.1.0/../../../../include/c++/8.1.0/bits/vector.tcc:446:13: note: in instantiation of function template specialization std::__uninitialized_move_if_noexcept_a<int *, int *, std::allocator<int> >
requested here
= std::__uninitialized_move_if_noexcept_a
^
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/8.1.0/../../../../include/c++/8.1.0/bits/vector.tcc:109:4:
note: in instantiation of function template specialization
std::vector<int, std::allocator<int> >::_M_realloc_insert<int>
requested here
_M_realloc_insert(end(), std::forward<_Args>(__args)...);
^
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/8.1.0/../../../../include/c++/8.1.0/bits/stl_vector.h:1091:9:
note: in instantiation of function template specialization
std::vector<int, std::allocator<int> >::emplace_back<int>
requested
here
{ emplace_back(std::move(__x)); }
^
main.cpp:7:9: note: in instantiation of member function
std::vector<int, std::allocator<int> >::push_back
requested here
bombs.push_back(42);
^
4 errors generated.
与 g++ 相同,编译没有任何问题。我真的不能看
Coliru 的 Clang 包含的库 headers 用于编程以自行解决。有谁知道哪里出了问题以及如何解决这个问题?
我 100% 不会担心这个,这只是 Coliru 的一些怪事。它在 Wandbox 上完美运行,回到 Clang 3.1
根据 donations page,您可能可以将此问题报告给 [电子邮件地址已编辑]。
See it here. 程序很平凡,像这样:
#include <vector>
std::vector<int> bombs;
int main()
{
bombs.push_back(42); // compile errors
}
诊断对我来说意义不大:
In file included from main.cpp:1:
In file included from /usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/8.1.0/../../../../include/c++/8.1.0/vector:60:
In file included from /usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/8.1.0/../../../../include/c++/8.1.0/bits/stl_algobase.h:64:
In file included from /usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/8.1.0/../../../../include/c++/8.1.0/bits/stl_pair.h:59:
In file included from /usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/8.1.0/../../../../include/c++/8.1.0/bits/move.h:55:
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/8.1.0/../../../../include/c++/8.1.0/type_traits:1061:48: error: '_Tp' does not refer to a value
: public __bool_constant<__is_assignable(_Tp, _Up)> ^
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/8.1.0/../../../../include/c++/8.1.0/type_traits:1059:21: note: declared here
template<typename _Tp, typename _Up> ^
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/8.1.0/../../../../include/c++/8.1.0/type_traits:1061:53: error:
_Up
does not refer to a value: public __bool_constant<__is_assignable(_Tp, _Up)> ^
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/8.1.0/../../../../include/c++/8.1.0/type_traits:1059:35: note: declared here
template<typename _Tp, typename _Up> ^
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/8.1.0/../../../../include/c++/8.1.0/type_traits:1062:5: error: expected class name
{ }; ^
In file included from main.cpp:1:
In file included from /usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/8.1.0/../../../../include/c++/8.1.0/vector:63:
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/8.1.0/../../../../include/c++/8.1.0/bits/stl_uninitialized.h:128:70: error: no member named
value
instd::is_assignable<int &, int &&>
const bool __assignable = is_assignable<_RefType2, _RefType1>::value; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/8.1.0/../../../../include/c++/8.1.0/bits/stl_uninitialized.h:289:19: note: in instantiation of function template specialization
std::uninitialized_copy<std::move_iterator<int *>, int *>
requested here{ return std::uninitialized_copy(__first, __last, __result); } ^
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/8.1.0/../../../../include/c++/8.1.0/bits/stl_uninitialized.h:310:19: note: in instantiation of function template specialization
std::__uninitialized_copy_a<std::move_iterator<int *>, int *, int>
requested herereturn std::__uninitialized_copy_a ^
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/8.1.0/../../../../include/c++/8.1.0/bits/vector.tcc:446:13: note: in instantiation of function template specialization
std::__uninitialized_move_if_noexcept_a<int *, int *, std::allocator<int> >
requested here= std::__uninitialized_move_if_noexcept_a ^
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/8.1.0/../../../../include/c++/8.1.0/bits/vector.tcc:109:4: note: in instantiation of function template specialization
std::vector<int, std::allocator<int> >::_M_realloc_insert<int>
requested here_M_realloc_insert(end(), std::forward<_Args>(__args)...); ^
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/8.1.0/../../../../include/c++/8.1.0/bits/stl_vector.h:1091:9: note: in instantiation of function template specialization
std::vector<int, std::allocator<int> >::emplace_back<int>
requested here{ emplace_back(std::move(__x)); } ^
main.cpp:7:9: note: in instantiation of member function
std::vector<int, std::allocator<int> >::push_back
requested herebombs.push_back(42); ^
4 errors generated.
与 g++ 相同,编译没有任何问题。我真的不能看 Coliru 的 Clang 包含的库 headers 用于编程以自行解决。有谁知道哪里出了问题以及如何解决这个问题?
我 100% 不会担心这个,这只是 Coliru 的一些怪事。它在 Wandbox 上完美运行,回到 Clang 3.1
根据 donations page,您可能可以将此问题报告给 [电子邮件地址已编辑]。