[cfe-dev] libc++ problem with clang trunk

David Irvine david.irvine at maidsafe.net
Mon Nov 11 06:16:17 PST 2013


On Wed, Nov 6, 2013 at 5:53 PM, Howard Hinnant <hhinnant at apple.com> wrote:

> Fixed in r194154.
>
> Howard
>
> On Nov 6, 2013, at 7:40 AM, İsmail Dönmez <ismail at donmez.ws> wrote:
>
> > 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 <memory>
> > using namespace std;
> >
> > class test {
> >         struct private_tag {};
> > public:
> >         test(private_tag) {}
> >         static shared_ptr<test> make_test() {
> >                 return make_shared<test>(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 &&,
> >       false>::__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<test>
> >::__shared_ptr_emplace<test::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<test>::make_shared<test::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<test>(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.
> >
>
>
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 <vector>
#include <future>
#include <memory>
#include <thread>


struct TestStruct {
    int index;
};

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


int main() {
  Do<TestStruct>();
  // Do();
}


Best Regards
David Irvine
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131111/4851cef3/attachment.html>


More information about the cfe-dev mailing list