Patchwork [v3] PATCH to add non-const deleted thread copy constructor

login
register
mail settings
Submitter Jason Merrill
Date Aug. 6, 2010, 7:42 p.m.
Message ID <4C5C65B3.5070106@redhat.com>
Download mbox | patch
Permalink /patch/61144/
State New
Headers show

Comments

Jason Merrill - Aug. 6, 2010, 7:42 p.m.
We've previously discussed using SFINAE to prevent an ill-formed attempt 
to copy a thread from matching the variadic constructor, but a simpler 
solution is just to declare the non-const copy ctor as well as the usual 
const variant.

Tested x86_64-pc-linux-gnu, approved by bkoz, applied to trunk.

Patch

commit ff423279eebaa909e271f4a0f72e23718aec6fe5
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Aug 4 16:37:40 2010 +0200

    	* include/std/thread: Add deleted thread(thread&).

diff --git a/libstdc++-v3/include/std/thread b/libstdc++-v3/include/std/thread
index c348c76..8007edc 100644
--- a/libstdc++-v3/include/std/thread
+++ b/libstdc++-v3/include/std/thread
@@ -123,6 +123,7 @@  namespace std
 
   public:
     thread() = default;
+    thread(thread&) = delete;
     thread(const thread&) = delete;
 
     thread(thread&& __t)
diff --git a/libstdc++-v3/testsuite/30_threads/thread/cons/copy_neg.cc b/libstdc++-v3/testsuite/30_threads/thread/cons/copy_neg.cc
index db06e72..9d8681d 100644
--- a/libstdc++-v3/testsuite/30_threads/thread/cons/copy_neg.cc
+++ b/libstdc++-v3/testsuite/30_threads/thread/cons/copy_neg.cc
@@ -27,13 +27,7 @@  void test01()
   // copy
   typedef std::thread test_type;
   test_type t1;
-  test_type t2(t1);		// { dg-error "deleted" "" { xfail *-*-* } }
+  test_type t2(t1);		// { dg-error "deleted" }
 }
 
-// This is failing for the wrong reason; it should fail because we're
-// trying to call the deleted copy constructor, but instead it fails
-// because we try to call the thread(_Callable&&,_Args&&...) constructor
-// and fail because thread isn't callable.  But that's OK for now.
-// { dg-error "" "" { target *-*-* } 30 }
-
 // { dg-prune-output "include" }