[cfe-dev] thread(F&&) fails when F is not MoveAssignable
Gordon Henriksen
gordonhenriksen at me.com
Sun Dec 16 17:08:45 PST 2012
On 2012-12-16, at 16:23, Howard Hinnant wrote:
> On Dec 16, 2012, at 7:16 PM, Gordon Henriksen <gordonhenriksen at me.com> wrote:
>
>> On 2012-12-16, at 15:49, Gordon Henriksen wrote:
>>
>>> On 2012-12-16, at 15:36, Howard Hinnant wrote:
>>>
>>>> let's zero in on a precise copy/pasteable test.
>>>
>>> Agreed. I'm attempting to reduce a test case.
>>
>> Found it; the correct reduction has one additional line:
>>
>> #define decltype __typeof // CULPRIT
>>
>> #ifdefing out that 'help' for clang permits the test to work without modification.
>>
>> Reduction is below.
>>
>> — Gordon
>
> Interesting. Nice detective work.
>
> I'm actually not duplicating your symptoms, but that may be because I currently have later versions of libc++ installed. Your detective work seems spot-on to me. test bug.
I do reproduce with the item from the previous e-mail. I thought for a moment I didn't, but it was because of an error I missed on the cat <<'EOT' >test.cpp:
zsh: file exists: test.cpp
Anyhow, hopefully your explanation is right, and this is fixed in development. :)
— Gordon
$ cat fail.cpp
#define decltype __typeof
#include <thread>
namespace {
class SimpleJoinThread {
bool &flag_;
public:
SimpleJoinThread(bool &flag) : flag_(flag) { }
void operator()() { flag_ = true; }
};
}
int main() {
bool flag = false;
std::thread(SimpleJoinThread(flag)).join();
}
$ diff -u fail.cpp pass.cpp
--- fail.cpp 2012-12-16 16:54:56.000000000 -0800
+++ pass.cpp 2012-12-16 16:55:46.000000000 -0800
@@ -1,4 +1,3 @@
-#define decltype __typeof
#include <thread>
namespace {
$ openssl sha1 *.cpp
SHA1(fail.cpp)= 21b5bbfdbf7bbc160efe531c443d9030664449b7
SHA1(pass.cpp)= a3d444faeebc43011d7ea674e048062029aa4719
$ xcrun clang++ -std=c++0x -stdlib=libc++ -o pass pass.cpp
$ ./pass
$ xcrun clang++ -std=c++0x -stdlib=libc++ -o fail fail.cpp
In file included from fail.cpp:2:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/thread:90:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/__functional_base:15:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/type_traits:3055:22: error: attempt to use a deleted
function
typedef decltype(swap(_VSTD::declval<_Tp&>(), _VSTD::declval<_Tp&>())) type;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/type_traits:3063:48: note: in instantiation of template
class 'std::__1::__detail::__swappable<<anonymous>::SimpleJoinThread>' requested here
: public integral_constant<bool, __detail::__swappable<_Tp>::value>
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/type_traits:3084:41: note: in instantiation of template
class 'std::__1::__is_swappable<<anonymous>::SimpleJoinThread>' requested here
: public __is_nothrow_swappable_imp<__is_swappable<_Tp>::value, _Tp>
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/tuple:217:16: note: in instantiation of template class
'std::__1::__is_nothrow_swappable<<anonymous>::SimpleJoinThread>' requested here
_NOEXCEPT_(__is_nothrow_swappable<_Hp>::value)
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/__config:253:34: note: expanded from macro '_NOEXCEPT_'
# define _NOEXCEPT_(x) noexcept(x)
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/tuple:216:6: note: in instantiation of function template
specialization 'std::__1::swap<0, <anonymous>::SimpleJoinThread, false>' requested here
void swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y)
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/type_traits:3063:48: note: in instantiation of template
class 'std::__1::__detail::__swappable<std::__1::__tuple_leaf<0, <anonymous>::SimpleJoinThread, false>>' requested here
: public integral_constant<bool, __detail::__swappable<_Tp>::value>
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/type_traits:3084:41: note: (skipping 1 context in
backtrace; use -ftemplate-backtrace-limit=0 to see all)
: public __is_nothrow_swappable_imp<__is_swappable<_Tp>::value, _Tp>
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/tuple:332:44: note: in instantiation of template class
'std::__1::__is_nothrow_swappable<std::__1::__tuple_leaf<0, <anonymous>::SimpleJoinThread, false>>' requested here
int swap(__tuple_leaf& __t) _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value)
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/__config:253:34: note: expanded from macro '_NOEXCEPT_'
# define _NOEXCEPT_(x) noexcept(x)
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/tuple:436:14: note: in instantiation of template class
'std::__1::__tuple_leaf<0, <anonymous>::SimpleJoinThread, false>' requested here
: public __tuple_leaf<_Indx, _Tp>...
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/tuple:523:10: note: in instantiation of template class
'std::__1::__tuple_impl<std::__1::__tuple_indices<0>, <anonymous>::SimpleJoinThread>' requested here
base base_;
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/thread:350:36: note: in instantiation of template class
'std::__1::tuple<<anonymous>::SimpleJoinThread>' requested here
_VSTD::unique_ptr<_Gp> __p(new _Gp(__decay_copy(_VSTD::forward<_Fp>(__f)),
^
fail.cpp:15:2: note: in instantiation of function template specialization 'std::__1::thread::thread<<anonymous>::SimpleJoinThread, , void>' requested here
std::thread(SimpleJoinThread(flag)).join();
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/type_traits:825:5: note: function has been explicitly
marked deleted here
~__nat() = delete;
^
1 error generated.
$
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fail.cpp
Type: application/octet-stream
Size: 297 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121216/791bc1a6/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pass.cpp
Type: application/octet-stream
Size: 270 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121216/791bc1a6/attachment-0001.obj>
More information about the cfe-dev
mailing list