It's not possible to push_back in a vector of std::thread because std::thread is not copy-constructible. And moving to emplace_back triggers a method lookup error related to the custom allocator, as showcased in https://godbolt.org/z/jsbEKC.
Details
Diff Detail
- Repository
- rCRT Compiler Runtime
Event Timeline
LGTM, but one of the code owners would need to sign of.
The benefit is not creating the temporary object, right?
Yeah, especially as he copy constructor is deleted, push_back implies a copy, so relying on the compiler to optimize to a move seems fragile.
There should be an rvalue overload of std::vector<T>::push_back - is there not? ( https://en.cppreference.com/w/cpp/container/vector/push_back )
Right! https://godbolt.org/z/c3iMsT proves you right. The part that actually matters seems to be the `construct` member forwarding (why is inheritance not enough in that case?).
That failure appears only on trunk GCC/libstdc++, by the looks of it? Does it matter that Clang doesn't compile on an unreleased compiler? (8.2 seems to compile the example OK) I can't seem to find a convenient web view of the current libstdc++ sources, so I'm only guessing, but that might well be a bug in trunk libstdc++.
Fedora is currently using gcc-9.0.1, svn revision 268719 (see https://src.fedoraproject.org/rpms/gcc/blob/master/f/gcc.spec) which triggers this issue. I'll forward the test case to the gcc team and report here.
GCC 9 isn't released yet, though - is this a release of Redhat or more "in-development Redhat is using in-development GCC"?
But yeah, I'd check with libstdc++ folks to see if this is a bug there. Vaguely looks like it.
I've reported this strange behavior to gcc https://bugzilla.redhat.com/show_bug.cgi?id=1678613
- I am not sure what problem does it solve. Everything seems to work.
- We can now safely remove fuzzer_allocator and rename Vector to just plain std::vector. (we don't need this monstrosity any more since we are using private STL now)
It was a workaround for a bug in an unreleased version of libstdc++ - nothing to fix on our end.
I think this change should be abandoned.
I confirm the bug has been fixed in trunk gcc and in fedora rawhide's gcc, closing the issue.
please clang-format