https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89416

            Bug ID: 89416
           Summary: [regression] std::vector<std::thread,
                    custom_allocator>::push_back no longer builds.
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: emilio at crisal dot io
  Target Milestone: ---

Created attachment 45772
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45772&action=edit
Test-case.

The attached test-case no longer builds.

It's a reduction from:

 
https://searchfox.org/mozilla-central/rev/93905b660fc99a5d52b683690dd26471daca08c8/tools/fuzzing/libfuzzer/FuzzerDriver.cpp#244

Both g++ and clang error. g++ errors with:

In file included from
/usr/include/c++/9/x86_64-redhat-linux/bits/c++allocator.h:33,
                 from /usr/include/c++/9/bits/allocator.h:46,
                 from /usr/include/c++/9/memory:63,
                 from /usr/include/c++/9/thread:39,
                 from t.cpp:1:
/usr/include/c++/9/ext/new_allocator.h: In instantiation of ‘void
__gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up =
std::thread; _Args = {const std::thread&}; _Tp = std::thread]’:
/usr/include/c++/9/bits/alloc_traits.h:226:6:   required by substitution of
‘template<class _Alloc2, class> static std::true_type
std::allocator_traits<fuzzer_allocator<std::thread>
>::__construct_helper<std::thread, const std::thread&>::__test<_Alloc2,
<template-parameter-1-2> >(int) [with _Alloc2 = fuzzer_allocator<std::thread>;
<template-parameter-1-2> = <missing>]’
/usr/include/c++/9/bits/alloc_traits.h:233:40:   required from ‘struct
std::allocator_traits<fuzzer_allocator<std::thread>
>::__construct_helper<std::thread, const std::thread&>’
/usr/include/c++/9/bits/alloc_traits.h:250:2:   required by substitution of
‘template<class _Tp, class ... _Args> static
std::_Require<std::__and_<std::__not_<typename
std::allocator_traits<fuzzer_allocator<std::thread> >::__construct_helper<_Tp,
_Args>::type>, std::is_constructible<_Tp, _Args ...> > >
std::allocator_traits<fuzzer_allocator<std::thread> >::_S_construct<_Tp, _Args
...>(fuzzer_allocator<std::thread>&, _Tp*, _Args&& ...) [with _Tp =
std::thread; _Args = {const std::thread&}]’
/usr/include/c++/9/bits/alloc_traits.h:350:26:   required by substitution of
‘template<class _Tp, class ... _Args> static decltype
(std::allocator_traits<fuzzer_allocator<std::thread> >::_S_construct(__a, __p,
(forward<_Args>)(std::allocator_traits::construct::__args)...))
std::allocator_traits<fuzzer_allocator<std::thread> >::construct<_Tp, _Args
...>(fuzzer_allocator<std::thread>&, _Tp*, _Args&& ...) [with _Tp =
std::thread; _Args = {const std::thread&}]’
/usr/include/c++/9/bits/alloc_traits.h:587:38:   required by substitution of
‘template<class _Up, class _Tp, class> static std::true_type
std::__is_alloc_insertable_impl<fuzzer_allocator<std::thread> >::_M_select<_Up,
_Tp, <template-parameter-1-3> >(int) [with _Up = const std::thread&; _Tp =
std::thread; <template-parameter-1-3> = <missing>]’
/usr/include/c++/9/bits/alloc_traits.h:598:57:   required from ‘class
std::__is_alloc_insertable_impl<fuzzer_allocator<std::thread> >’
/usr/include/c++/9/bits/alloc_traits.h:616:12:   required from ‘struct
std::__is_move_insertable<fuzzer_allocator<std::thread> >’
/usr/include/c++/9/bits/stl_vector.h:446:28:   required from ‘static constexpr
bool std::vector<_Tp, _Alloc>::_S_use_relocate() [with _Tp = std::thread;
_Alloc = fuzzer_allocator<std::thread>]’
/usr/include/c++/9/bits/vector.tcc:459:44:   required from ‘void
std::vector<_Tp, _Alloc>::_M_realloc_insert(std::vector<_Tp, _Alloc>::iterator,
_Args&& ...) [with _Args = {void (&)()}; _Tp = std::thread; _Alloc =
fuzzer_allocator<std::thread>; std::vector<_Tp, _Alloc>::iterator =
__gnu_cxx::__normal_iterator<std::thread*, std::vector<std::thread,
fuzzer_allocator<std::thread> > >; typename std::_Vector_base<_Tp,
_Alloc>::pointer = std::thread*]’
/usr/include/c++/9/bits/vector.tcc:121:4:   required from ‘void
std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {void (&)()};
_Tp = std::thread; _Alloc = fuzzer_allocator<std::thread>]’
t.cpp:30:30:   required from here
/usr/include/c++/9/ext/new_allocator.h:145:20: error: use of deleted function
‘std::thread::thread(const std::thread&)’
  145 |  noexcept(noexcept(::new((void *)__p)
      |                    ^~~~~~~~~~~~~~~~~~
  146 |        _Up(std::forward<_Args>(__args)...)))
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from t.cpp:1:
/usr/include/c++/9/thread:142:5: note: declared here
  142 |     thread(const thread&) = delete;
      |     ^~~~~~


clang++ errors with:

In file included from t.cpp:1:
In file included from
/usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/thread:39:
In file included from
/usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/memory:63:
In file included from
/usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/allocator.h:46:
In file included from
/usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/x86_64-redhat-linux/bits/c++allocator.h:33:
/usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/ext/new_allocator.h:146:8:
error: call to deleted constructor of 'std::thread'
                            _Up(std::forward<_Args>(__args)...)))
                            ^   ~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/alloc_traits.h:226:52:
note: in instantiation of exception specification for
      'construct<std::thread, const std::thread &>' requested here
            typename = decltype(std::declval<_Alloc2*>()->construct(
                                                          ^
/usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/alloc_traits.h:228:23:
note: in instantiation of default argument for
'__test<fuzzer_allocator<std::thread> >'
      required here
            static true_type __test(int);
                             ^~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/alloc_traits.h:233:26:
note: while substituting deduced template arguments into function template
'__test' [with
      _Alloc2 = fuzzer_allocator<std::thread>, $1 = (no value)]
          using type = decltype(__test<_Alloc>(0));
                                ^
/usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/alloc_traits.h:237:2:
note: in instantiation of template class
'std::allocator_traits<fuzzer_allocator<std::thread>
      >::__construct_helper<std::thread, const std::thread &>' requested here
        using __has_construct
        ^
/usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/alloc_traits.h:248:25:
note: in instantiation of template type alias '__has_construct' requested here
        _Require<__and_<__not_<__has_construct<_Tp, _Args...>>,
                               ^
/usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/alloc_traits.h:350:14:
note: (skipping 5 contexts in backtrace; use -ftemplate-backtrace-limit=0 to
see all)
        -> decltype(_S_construct(__a, __p, std::forward<_Args>(__args)...))
                    ^
/usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/stl_vector.h:446:29:
note: in instantiation of template class
      'std::__is_move_insertable<fuzzer_allocator<std::thread> >' requested
here
        return _S_nothrow_relocate(__is_move_insertable<_Tp_alloc_type>{});
                                   ^
/usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/vector.tcc:459:29:
note: in instantiation of member function 'std::vector<std::thread,
fuzzer_allocator<std::thread>
      >::_S_use_relocate' requested here
          if _GLIBCXX17_CONSTEXPR (_S_use_relocate())
                                   ^
/usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/vector.tcc:121:4:
note: in instantiation of function template specialization
'std::vector<std::thread,
      fuzzer_allocator<std::thread> >::_M_realloc_insert<std::thread>'
requested here
          _M_realloc_insert(end(), std::forward<_Args>(__args)...);
          ^
/usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/bits/stl_vector.h:1201:9:
note: in instantiation of function template specialization
'std::vector<std::thread,
      fuzzer_allocator<std::thread> >::emplace_back<std::thread>' requested
here
      { emplace_back(std::move(__x)); }
        ^
t.cpp:25:5: note: in instantiation of member function 'std::vector<std::thread,
fuzzer_allocator<std::thread> >::push_back' requested here
  V.push_back(std::thread(WorkerThread));
    ^
/usr/bin/../lib/gcc/x86_64-redhat-linux/9/../../../../include/c++/9/thread:142:5:
note: 'thread' has been explicitly marked deleted here
    thread(const thread&) = delete;
    ^
1 error generated.

gcc -v:

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap
--enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,lto --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared
--enable-threads=posix --enable-checking=release --enable-multilib
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-gnu-unique-object --enable-linker-build-id
--with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin
--enable-initfini-array --with-isl --enable-offload-targets=nvptx-none
--without-cuda-driver --enable-gnu-indirect-function --enable-cet
--with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 9.0.1 20190209 (Red Hat 9.0.1-0.4) (GCC) 

clang -v

clang version 7.0.1 (Fedora 7.0.1-6.fc30)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-redhat-linux/9
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/9
Found candidate GCC installation: /usr/lib/gcc/i686-redhat-linux/9
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/9
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-redhat-linux/9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64

Reply via email to