public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix exception-specification of std::invoke
@ 2016-10-13  8:55 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2016-10-13  8:55 UTC (permalink / raw)
  To: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 370 bytes --]

The arguments to the is_nothrow_callable traits were not adding && to
the types, so they failed with anything that formed an invalid
function type.

	* include/bits/invoke.h (__invoke): Fix exception-specification.
	* include/std/functional (invoke): Likewise.
	* testsuite/20_util/function_objects/invoke/1.cc: New test.

Tested powerpc64le-linux, committed to trunk.


[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 3049 bytes --]

commit e799357d09cf2d731a50a36ade71a39104eef6e5
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Oct 13 01:38:29 2016 +0100

    Fix exception-specification of std::invoke
    
    	* include/bits/invoke.h (__invoke): Fix exception-specification.
    	* include/std/functional (invoke): Likewise.
    	* testsuite/20_util/function_objects/invoke/1.cc: New test.

diff --git a/libstdc++-v3/include/bits/invoke.h b/libstdc++-v3/include/bits/invoke.h
index 60405b5..2bbdab7 100644
--- a/libstdc++-v3/include/bits/invoke.h
+++ b/libstdc++-v3/include/bits/invoke.h
@@ -87,7 +87,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<typename _Callable, typename... _Args>
     constexpr typename result_of<_Callable&&(_Args&&...)>::type
     __invoke(_Callable&& __fn, _Args&&... __args)
-    noexcept(__is_nothrow_callable<_Callable(_Args&&...)>::value)
+    noexcept(__is_nothrow_callable<_Callable&&(_Args&&...)>::value)
     {
       using __result_of = result_of<_Callable&&(_Args&&...)>;
       using __type = typename __result_of::type;
diff --git a/libstdc++-v3/include/std/functional b/libstdc++-v3/include/std/functional
index 2587392..6a45314 100644
--- a/libstdc++-v3/include/std/functional
+++ b/libstdc++-v3/include/std/functional
@@ -200,7 +200,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<typename _Callable, typename... _Args>
     inline result_of_t<_Callable&&(_Args&&...)>
     invoke(_Callable&& __fn, _Args&&... __args)
-    noexcept(is_nothrow_callable_v<_Callable(_Args&&...)>)
+    noexcept(is_nothrow_callable_v<_Callable&&(_Args&&...)>)
     {
       return std::__invoke(std::forward<_Callable>(__fn),
 			   std::forward<_Args>(__args)...);
diff --git a/libstdc++-v3/testsuite/20_util/function_objects/invoke/1.cc b/libstdc++-v3/testsuite/20_util/function_objects/invoke/1.cc
new file mode 100644
index 0000000..81bf25a
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/function_objects/invoke/1.cc
@@ -0,0 +1,30 @@
+// Copyright (C) 2016 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do compile { target c++11 } }
+
+#include <functional>
+
+struct abstract {
+  virtual ~abstract() = 0;
+  void operator()() noexcept;
+};
+
+static_assert( noexcept(std::__invoke(std::declval<abstract>())), "" );
+#if __cpp_lib_invoke
+static_assert( noexcept(std::invoke(std::declval<abstract>())), "" );
+#endif

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-10-13  8:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-13  8:55 [PATCH] Fix exception-specification of std::invoke Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).