Search code examples
c++clang++coliru

Why Clang at Coliru can't compile vector::push_back?


See it here. The program is very mundane, like that:

#include <vector>

std::vector<int> bombs;

int main()
{
    bombs.push_back(42); // compile errors
}

The diagnostics do not make much sense to me:

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.

Same with g++ compiles without any issues. I can't really look at the library headers that Clang at Coliru includes to program for to figure it out myself. Does anyone have any ideas what is wrong and how to overcome the issue?


Solution

  • I 100% wouldn't worry about this, it's just some weirdness at Coliru. It works perfectly at Wandbox, right back to Clang 3.1

    According to the donations page, you can probably report this problem to [email address redacted].