Re: [patch] fix libstdc++/55861

2013-09-26 Thread Jonathan Wakely
On 19 January 2013 23:43, Jonathan Wakely wrote:
 PR libstdc++/55861
 * include/std/future (_State_base::_S_check(const shared_ptrT)):
 Fix return type.
 (__basic_future::_M_get_result()): Const qualify.
 (shared_future::get()): Likewise.
 * testsuite/30_threads/shared_future/members/get.cc: Use const
 objects.

 Tested x86_64-linux, committed to trunk.

I've backported the first part of this, fixing the return type, to the
4.7 branch.

Unfortunately it makes std::future unusable with clang, see
http://llvm.org/bugs/show_bug.cgi?id=17375

Tested x86_64-linux, committed to the 4.7 branch.
commit e2829e7c39c153cfc0d09cd8a8be14c5467c7730
Author: Jonathan Wakely jwakely@gmail.com
Date:   Thu Sep 26 10:11:29 2013 +0100

Backport from mainline

2013-01-19  Jonathan Wakely  jwakely@gmail.com

PR libstdc++/55861
* include/std/future (_State_base::_S_check(const shared_ptrT)):
Fix return type.

diff --git a/libstdc++-v3/include/std/future b/libstdc++-v3/include/std/future
index 98c7b84..150c1af 100644
--- a/libstdc++-v3/include/std/future
+++ b/libstdc++-v3/include/std/future
@@ -1,6 +1,6 @@
 // future -*- C++ -*-
 
-// Copyright (C) 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+// Copyright (C) 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -456,7 +456,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   __setter(promisevoid* __prom);
 
   templatetypename _Tp
-static bool
+static void
 _S_check(const shared_ptr_Tp __p)
 {
   if (!static_castbool(__p))


[patch] fix libstdc++/55861

2013-01-19 Thread Jonathan Wakely
PR libstdc++/55861
* include/std/future (_State_base::_S_check(const shared_ptrT)):
Fix return type.
(__basic_future::_M_get_result()): Const qualify.
(shared_future::get()): Likewise.
* testsuite/30_threads/shared_future/members/get.cc: Use const
objects.

Tested x86_64-linux, committed to trunk.
commit 0b1ce87e22ebcefbc19c9b26d58a1cd2a2654297
Author: Jonathan Wakely jwakely@gmail.com
Date:   Sat Jan 19 21:02:13 2013 +

PR libstdc++/55861
* include/std/future (_State_base::_S_check(const shared_ptrT)):
Fix return type.
(__basic_future::_M_get_result()): Const qualify.
(shared_future::get()): Likewise.
* testsuite/30_threads/shared_future/members/get.cc: Use const
objects.

diff --git a/libstdc++-v3/include/std/future b/libstdc++-v3/include/std/future
index 2ecf438..6cccd3d 100644
--- a/libstdc++-v3/include/std/future
+++ b/libstdc++-v3/include/std/future
@@ -1,6 +1,6 @@
 // future -*- C++ -*-
 
-// Copyright (C) 2009-2012 Free Software Foundation, Inc.
+// Copyright (C) 2009-2013 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -447,7 +447,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   __setter(promisevoid* __prom);
 
   templatetypename _Tp
-static bool
+static void
 _S_check(const shared_ptr_Tp __p)
 {
   if (!static_castbool(__p))
@@ -583,7 +583,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 protected:
   /// Wait for the state to be ready and rethrow any stored exception
   __result_type
-  _M_get_result()
+  _M_get_result() const
   {
 _State_base::_S_check(_M_state);
 _Result_base __res = _M_state-wait();
@@ -794,12 +794,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   /// Retrieving the value
   const _Res
-  get()
-  {
-   typename _Base_type::__result_type __r = this-_M_get_result();
-   _Res __rs(__r._M_value());
-   return __rs;
-  }
+  get() const { return this-_M_get_result()._M_value(); }
 };
 
   /// Partial specialization for shared_futureR
@@ -838,7 +833,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   /// Retrieving the value
   _Res
-  get() { return this-_M_get_result()._M_get(); }
+  get() const { return this-_M_get_result()._M_get(); }
 };
 
   /// Explicit specialization for shared_futurevoid
@@ -877,7 +872,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   // Retrieving the value
   void
-  get() { this-_M_get_result(); }
+  get() const { this-_M_get_result(); }
 };
 
   // Now we can define the protected __basic_future constructors.
diff --git a/libstdc++-v3/testsuite/30_threads/shared_future/members/get.cc 
b/libstdc++-v3/testsuite/30_threads/shared_future/members/get.cc
index 4c8ef82..9d2628d 100644
--- a/libstdc++-v3/testsuite/30_threads/shared_future/members/get.cc
+++ b/libstdc++-v3/testsuite/30_threads/shared_future/members/get.cc
@@ -6,7 +6,7 @@
 // { dg-require-gthreads  }
 // { dg-require-atomic-builtins  }
 
-// Copyright (C) 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+// Copyright (C) 2009-2013 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -34,7 +34,7 @@ void test01()
   bool test __attribute__((unused)) = true;
 
   std::promiseint p1;
-  std::shared_futureint f1(p1.get_future());
+  const std::shared_futureint f1(p1.get_future());
   std::shared_futureint f2(f1);
 
   p1.set_value(value);
@@ -47,7 +47,7 @@ void test02()
   bool test __attribute__((unused)) = true;
 
   std::promiseint p1;
-  std::shared_futureint f1(p1.get_future());
+  const std::shared_futureint f1(p1.get_future());
   std::shared_futureint f2(f1);
 
   p1.set_value(value);
@@ -60,7 +60,7 @@ void test03()
   bool test __attribute__((unused)) = true;
 
   std::promisevoid p1;
-  std::shared_futurevoid f1(p1.get_future());
+  const std::shared_futurevoid f1(p1.get_future());
   std::shared_futurevoid f2(f1);
 
   p1.set_value();