libc++ problem with clang trunk

Hi,

Testcase stolen from #llvm channel, using clang r194134 on Linux x86-64.
This is also reported as http://llvm.org/bugs/show_bug.cgi?id=17826

[/havana/t/clang]> cat test.cpp
#include
using namespace std;

class test {
struct private_tag {};
public:
test(private_tag) {}
static shared_ptr make_test() {
return make_shared(private_tag());
}
};

int main()
{
auto t = test::make_test();
}

[/havana/t/clang]> clang++ -std=c++11 -stdlib=libc++ test.cpp
In file included from test.cpp:1:
In file included from /usr/include/c++/v1/memory:603:
/usr/include/c++/v1/tuple:267:11: error: rvalue reference to type ‘test::private_tag’ cannot bind to lvalue of type
‘test::private_tag’
: value(__t.get())
^ ~~~~~~~~~
/usr/include/c++/v1/tuple:385:8: note: in instantiation of member function 'std::__1::__tuple_leaf<0, test::private_tag &&,

::__tuple_leaf’ requested here
struct __tuple_impl<__tuple_indices<_Indx…>, _Tp…>
^
/usr/include/c++/v1/memory:4290:26: note: in instantiation of function template specialization
‘std::__1::__shared_ptr_emplace<test, std::__1::allocator >::__shared_ptr_emplacetest::private_tag’ requested
here
::new(__hold2.get()) _CntrlBlk(__a2, _VSTD::forward<_Args>(__args)…);
^
/usr/include/c++/v1/memory:4649:29: note: in instantiation of function template specialization
‘std::__1::shared_ptr::make_sharedtest::private_tag’ requested here
return shared_ptr<_Tp>::make_shared(_VSTD::forward<_Args>(__args)…);
^
test.cpp:9:24: note: in instantiation of function template specialization ‘std::__1::make_shared<test, test::private_tag>’
requested here
return make_shared(private_tag());
^
In file included from test.cpp:1:
In file included from /usr/include/c++/v1/memory:603:
/usr/include/c++/v1/tuple:268:10: error: static_assert failed “Can not copy a tuple with rvalue reference member”
{static_assert(!is_rvalue_reference<_Hp>::value, “Can not copy a tuple with rvalue reference member”);}
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 errors generated.

This is the same as

http://llvm.org/bugs/show_bug.cgi?id=17798
No?

If not the same, closely related. I'm working it...

Howard

Fixed in r194154.

Howard

Hi Howard, thank for the super quick fix, it helped us, but I think we have further errors that may be related. (I know this does not fall on you by default and sorry for any presumption.)

In the code below, if the Do function is templated (no need to use the template parameter) then the following code will not since last Thursday. This is compiled with
clang++ -std=c++11 -stdlib=libc++ -lc++abi -pthread test.cc

Using TOT for libc++abi libc++ and clang (clang from llvm repository) on ubuntu 13.10

Commenting out the template line and swapover the code in main, then this works perfectly OK. Using libstdc++ is also OK.

I hope this helps.

#include
#include
#include
#include

struct TestStruct {
int index;
};

template
void Do() {
auto v = std::make_shared<std::vector>(0, TestStruct());
auto fut(std::async(std::launch::async, [=] {
v->size();
}));
}

int main() {
Do();
// Do();
}

When I build this with "last week's" clang, it compiles fine.
When I build it with "this mornings" clang, clang crashes.

Created http://llvm.org/bugs/show_bug.cgi?id=17877

-- Marshall

Marshall Clow Idio Software <mailto:mclow.lists@gmail.com>

A.D. 1517: Martin Luther nails his 95 Theses to the church door and is promptly moderated down to (-1, Flamebait).
        -- Yu Suzuki