[cfe-dev] thread(F&&) fails when F is not MoveAssignable
Howard Hinnant
hhinnant at apple.com
Sun Dec 16 16:23:57 PST 2012
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
>
>
> cat <<'EOT' >test.cpp
> #define decltype __typeof // CULPRIT
> #include <thread>
> #include <iostream>
> #include <cassert>
>
> namespace {
> class SimpleJoinThread {
> bool &flag_;
> public:
> SimpleJoinThread(bool &flag) : flag_(flag) { }
> void operator()() { flag_ = true; }
> };
> } // End anonymous namespace.
>
> int main()
> {
> bool flag = false;
> std::thread(SimpleJoinThread(flag)).join();
> assert(flag);
> }
> EOT
>
> xcrun clang++ -std=c++0x -stdlib=libc++ test.cpp
> ./test
>
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.
Fwiw, libc++ does a similar dance in C++03 mode. <__config> has:
#if !(__has_feature(cxx_decltype))
#define _LIBCPP_HAS_NO_DECLTYPE
#endif
// ...
#ifdef _LIBCPP_HAS_NO_DECLTYPE
#define decltype(x) __typeof__(x)
#endif
Howard
More information about the cfe-dev
mailing list