dlib: Compiler error when building `test/serialize.cpp` on gcc 11

[1/3] Building CXX object CMakeFiles/dtest.dir/serialize.cpp.o
FAILED: CMakeFiles/dtest.dir/serialize.cpp.o 
/usr/bin/c++  -I/home/adria/Projects/reunanen/dlib/.. -O3 -DNDEBUG   -W -Wall -Wextra -Werror -Wno-unused-function -Wno-strict-overflow -DDLIB_JPEG_SUPPORT -DDLIB_USE_BLAS -DDLIB_USE_LAPACK -DDLIB_USE_CUDA -DDLIB_PNG_SUPPORT -DDLIB_GIF_SUPPORT -Wreturn-type -MD -MT CMakeFiles/dtest.dir/serialize.cpp.o -MF CMakeFiles/dtest.dir/serialize.cpp.o.d -o CMakeFiles/dtest.dir/serialize.cpp.o -c /home/adria/Projects/reunanen/dlib/test/serialize.cpp
In file included from /home/adria/Projects/reunanen/dlib/../dlib/memory_manager/../binary_search_tree/../serialize.h:241,
                 from /home/adria/Projects/reunanen/dlib/../dlib/memory_manager/../binary_search_tree/binary_search_tree_kernel_2.h:11,
                 from /home/adria/Projects/reunanen/dlib/../dlib/memory_manager/memory_manager_kernel_3.h:11,
                 from /home/adria/Projects/reunanen/dlib/../dlib/memory_manager.h:8,
                 from /home/adria/Projects/reunanen/dlib/../dlib/conditioning_class.h:13,
                 from /home/adria/Projects/reunanen/dlib/../dlib/compress_stream.h:10,
                 from /home/adria/Projects/reunanen/dlib/test/serialize.cpp:8:
/usr/include/c++/11.1.0/variant: In instantiation of ‘std::enable_if_t<((__exactly_once<std::variant<_Types>::__accepted_type<_Tp&&, typename std::enable_if<__not_self<_Tp&&>, void>::type> > && is_constructible_v<std::variant<_Types>::__accepted_type<_Tp&&, typename std::enable_if<__not_self<_Tp&&>, void>::type>, _Tp>) && is_assignable_v<std::variant<_Types>::__accepted_type<_Tp&&, typename std::enable_if<__not_self<_Tp&&>, void>::type>&, _Tp>), std::variant<_Types>&> std::variant<_Types>::operator=(_Tp&&) [with _Tp = const char (&)[40]; _Types = {int, float, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, {anonymous}::immutable_type}; std::enable_if_t<((__exactly_once<std::variant<_Types>::__accepted_type<_Tp&&, typename std::enable_if<__not_self<_Tp&&>, void>::type> > && is_constructible_v<std::variant<_Types>::__accepted_type<_Tp&&, typename std::enable_if<__not_self<_Tp&&>, void>::type>, _Tp>) && is_assignable_v<std::variant<_Types>::__accepted_type<_Tp&&, typename std::enable_if<__not_self<_Tp&&>, void>::type>&, _Tp>), std::variant<_Types>&> = std::variant<int, float, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, {anonymous}::immutable_type>&; std::variant<_Types>::__accepted_type<_Tp&&> = std::variant<int, float, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, {anonymous}::immutable_type>::__accepted_type<const char (&)[40], void>; typename std::enable_if<__not_self<_Tp&&>, void>::type = void]’:
/home/adria/Projects/reunanen/dlib/test/serialize.cpp:1155:16:   required from here
/usr/include/c++/11.1.0/variant:1445:26: error: use of deleted function ‘std::variant<_Types>& std::variant<_Types>::operator=(std::variant<_Types>&&) [with _Types = {int, float, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, {anonymous}::immutable_type}]’
 1445 |                 operator=(variant(std::forward<_Tp>(__rhs)));
      |                 ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/11.1.0/variant:1369:16: note: ‘std::variant<_Types>& std::variant<_Types>::operator=(std::variant<_Types>&&) [with _Types = {int, float, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, {anonymous}::immutable_type}]’ is implicitly deleted because the default definition would be ill-formed:
 1369 |       variant& operator=(variant&&) = default;
      |                ^~~~~~~~
/usr/include/c++/11.1.0/variant:1369:16: error: use of deleted function ‘std::_Enable_copy_move<false, false, false, false, _Tag>& std::_Enable_copy_move<false, false, false, false, _Tag>::operator=(std::_Enable_copy_move<false, false, false, false, _Tag>&&) [with _Tag = std::variant<int, float, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, {anonymous}::immutable_type>]’
In file included from /usr/include/c++/11.1.0/variant:38,
                 from /home/adria/Projects/reunanen/dlib/../dlib/memory_manager/../binary_search_tree/../serialize.h:241,
                 from /home/adria/Projects/reunanen/dlib/../dlib/memory_manager/../binary_search_tree/binary_search_tree_kernel_2.h:11,
                 from /home/adria/Projects/reunanen/dlib/../dlib/memory_manager/memory_manager_kernel_3.h:11,
                 from /home/adria/Projects/reunanen/dlib/../dlib/memory_manager.h:8,
                 from /home/adria/Projects/reunanen/dlib/../dlib/conditioning_class.h:13,
                 from /home/adria/Projects/reunanen/dlib/../dlib/compress_stream.h:10,
                 from /home/adria/Projects/reunanen/dlib/test/serialize.cpp:8:
/usr/include/c++/11.1.0/bits/enable_special_members.h:308:5: note: declared here
  308 |     operator=(_Enable_copy_move&&) noexcept                         = delete;
      |     ^~~~~~~~
In file included from /usr/include/c++/11.1.0/x86_64-pc-linux-gnu/bits/c++allocator.h:33,
                 from /usr/include/c++/11.1.0/bits/allocator.h:46,
                 from /usr/include/c++/11.1.0/string:41,
                 from /usr/include/c++/11.1.0/bits/locale_classes.h:40,
                 from /usr/include/c++/11.1.0/bits/ios_base.h:41,
                 from /usr/include/c++/11.1.0/ios:42,
                 from /usr/include/c++/11.1.0/ostream:38,
                 from /usr/include/c++/11.1.0/iostream:39,
                 from /home/adria/Projects/reunanen/dlib/test/serialize.cpp:5:
/usr/include/c++/11.1.0/ext/new_allocator.h: In instantiation of ‘void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = {anonymous}::my_custom_type; _Args = {const {anonymous}::my_custom_type&}; _Tp = {anonymous}::my_custom_type]’:
/usr/include/c++/11.1.0/bits/alloc_traits.h:512:17:   required from ‘static void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, _Up*, _Args&& ...) [with _Up = {anonymous}::my_custom_type; _Args = {const {anonymous}::my_custom_type&}; _Tp = {anonymous}::my_custom_type; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<{anonymous}::my_custom_type>]’
/usr/include/c++/11.1.0/bits/stl_vector.h:1192:30:   required from ‘void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = {anonymous}::my_custom_type; _Alloc = std::allocator<{anonymous}::my_custom_type>; std::vector<_Tp, _Alloc>::value_type = {anonymous}::my_custom_type]’
/home/adria/Projects/reunanen/dlib/test/serialize.cpp:1163:23:   required from here
/usr/include/c++/11.1.0/ext/new_allocator.h:156:11: error: use of deleted function ‘{anonymous}::my_custom_type::my_custom_type(const {anonymous}::my_custom_type&)’
  156 |         { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/adria/Projects/reunanen/dlib/test/serialize.cpp:430:12: note: ‘{anonymous}::my_custom_type::my_custom_type(const {anonymous}::my_custom_type&)’ is implicitly deleted because the default definition would be ill-formed:
  430 |     struct my_custom_type
      |            ^~~~~~~~~~~~~~
/home/adria/Projects/reunanen/dlib/test/serialize.cpp:430:12: error: use of deleted function ‘std::variant<_Types>::variant(const std::variant<_Types>&) [with _Types = {int, float, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, {anonymous}::immutable_type}]’
In file included from /home/adria/Projects/reunanen/dlib/../dlib/memory_manager/../binary_search_tree/../serialize.h:241,
                 from /home/adria/Projects/reunanen/dlib/../dlib/memory_manager/../binary_search_tree/binary_search_tree_kernel_2.h:11,
                 from /home/adria/Projects/reunanen/dlib/../dlib/memory_manager/memory_manager_kernel_3.h:11,
                 from /home/adria/Projects/reunanen/dlib/../dlib/memory_manager.h:8,
                 from /home/adria/Projects/reunanen/dlib/../dlib/conditioning_class.h:13,
                 from /home/adria/Projects/reunanen/dlib/../dlib/compress_stream.h:10,
                 from /home/adria/Projects/reunanen/dlib/test/serialize.cpp:8:
/usr/include/c++/11.1.0/variant:1366:7: note: ‘std::variant<_Types>::variant(const std::variant<_Types>&) [with _Types = {int, float, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, {anonymous}::immutable_type}]’ is implicitly deleted because the default definition would be ill-formed:
 1366 |       variant(const variant& __rhs) = default;
      |       ^~~~~~~
/usr/include/c++/11.1.0/variant:1366:7: error: use of deleted function ‘constexpr std::_Enable_copy_move<false, false, false, false, _Tag>::_Enable_copy_move(const std::_Enable_copy_move<false, false, false, false, _Tag>&) [with _Tag = std::variant<int, float, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, {anonymous}::immutable_type>]’
In file included from /usr/include/c++/11.1.0/variant:38,
                 from /home/adria/Projects/reunanen/dlib/../dlib/memory_manager/../binary_search_tree/../serialize.h:241,
                 from /home/adria/Projects/reunanen/dlib/../dlib/memory_manager/../binary_search_tree/binary_search_tree_kernel_2.h:11,
                 from /home/adria/Projects/reunanen/dlib/../dlib/memory_manager/memory_manager_kernel_3.h:11,
                 from /home/adria/Projects/reunanen/dlib/../dlib/memory_manager.h:8,
                 from /home/adria/Projects/reunanen/dlib/../dlib/conditioning_class.h:13,
                 from /home/adria/Projects/reunanen/dlib/../dlib/compress_stream.h:10,
                 from /home/adria/Projects/reunanen/dlib/test/serialize.cpp:8:
/usr/include/c++/11.1.0/bits/enable_special_members.h:303:15: note: declared here
  303 |     constexpr _Enable_copy_move(_Enable_copy_move const&) noexcept  = delete;
      |               ^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11.1.0/vector:66,
                 from /usr/include/c++/11.1.0/functional:62,
                 from /usr/include/c++/11.1.0/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11.1.0/algorithm:74,
                 from /home/adria/Projects/reunanen/dlib/../dlib/compress_stream/../algs.h:110,
                 from /home/adria/Projects/reunanen/dlib/../dlib/compress_stream/compress_stream_kernel_1.h:6,
                 from /home/adria/Projects/reunanen/dlib/../dlib/compress_stream.h:6,
                 from /home/adria/Projects/reunanen/dlib/test/serialize.cpp:8:
/usr/include/c++/11.1.0/bits/stl_uninitialized.h: In instantiation of ‘_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = std::move_iterator<{anonymous}::my_custom_type*>; _ForwardIterator = {anonymous}::my_custom_type*]’:
/usr/include/c++/11.1.0/bits/stl_uninitialized.h:333:37:   required from ‘_ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator, _ForwardIterator, std::allocator<_Tp>&) [with _InputIterator = std::move_iterator<{anonymous}::my_custom_type*>; _ForwardIterator = {anonymous}::my_custom_type*; _Tp = {anonymous}::my_custom_type]’
/usr/include/c++/11.1.0/bits/stl_uninitialized.h:355:2:   required from ‘_ForwardIterator std::__uninitialized_move_if_noexcept_a(_InputIterator, _InputIterator, _ForwardIterator, _Allocator&) [with _InputIterator = {anonymous}::my_custom_type*; _ForwardIterator = {anonymous}::my_custom_type*; _Allocator = std::allocator<{anonymous}::my_custom_type>]’
/usr/include/c++/11.1.0/bits/vector.tcc:474:3:   required from ‘void std::vector<_Tp, _Alloc>::_M_realloc_insert(std::vector<_Tp, _Alloc>::iterator, _Args&& ...) [with _Args = {const {anonymous}::my_custom_type&}; _Tp = {anonymous}::my_custom_type; _Alloc = std::allocator<{anonymous}::my_custom_type>; std::vector<_Tp, _Alloc>::iterator = std::vector<{anonymous}::my_custom_type>::iterator]’
/usr/include/c++/11.1.0/bits/stl_vector.h:1198:21:   required from ‘void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = {anonymous}::my_custom_type; _Alloc = std::allocator<{anonymous}::my_custom_type>; std::vector<_Tp, _Alloc>::value_type = {anonymous}::my_custom_type]’
/home/adria/Projects/reunanen/dlib/test/serialize.cpp:1163:23:   required from here
/usr/include/c++/11.1.0/bits/stl_uninitialized.h:138:72: error: static assertion failed: result type must be constructible from value type of input range
  138 |       static_assert(is_constructible<_ValueType2, decltype(*__first)>::value,
      |                                                                        ^~~~~
/usr/include/c++/11.1.0/bits/stl_uninitialized.h:138:72: note: ‘std::integral_constant<bool, false>::value’ evaluates to false

_Originally posted by @arrufat in https://github.com/davisking/dlib/pull/2490#discussion_r800174013_

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 19 (18 by maintainers)

Commits related to this issue

Most upvoted comments

I guess it wouldn’t be bad to add Clang to the build matrix, too… should be easy, but would have to know if this should be done on top of the current master, or #2509 (because otherwise there will be merge conflicts).

Whatever you find convenient. I am a big fan of branches off of branches. I normally have several dozen branches in a big branch forest 😄

If you put this in your .gitconfig then when you create a branch from inside another branch it will automatically set the upstream branch to the branch you branched from, making it easier to deal with:

[branch]
	autosetupmerge = always

There really should be a nice branch tree view command in git too. As far as I know there isn’t one around on the internet though. I’ve written nice tools for that at work but they aren’t public 😐

Would be cool if github actions tests ran with multiple versions of GCC.

I can try to make this happen.

I am also not a macOS user, so I don’t know exactly. Accoring to the cppreference compiler support page, they are a bit different.

It might also be that gcc 11.1.0 works correctly, where as gcc 9.3.0 and Visual Studio do not…

Ah, I’m also building it with GCC 11.1.0, so that’s definitely the problem.

For what it’s worth, this compiles and runs in Visual Studio. So I’m not sure it’s not a gcc bug.

Nevertheless, would be nice if the tests at least compiled just fine on stock Ubuntu 20.04.