public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-4500] libstdc++: Fix mem-initializer in std::move_only_function [PR102825]
@ 2021-10-19 10:50 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2021-10-19 10:50 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:9890b12c72c02828c691f22198c3e0afd8678991

commit r12-4500-g9890b12c72c02828c691f22198c3e0afd8678991
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Oct 19 09:16:56 2021 +0100

    libstdc++: Fix mem-initializer in std::move_only_function [PR102825]
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/102825
            * include/bits/mofunc_impl.h (move_only_function): Remove
            invalid base initializer.
            * testsuite/20_util/move_only_function/cons.cc: Instantiate
            constructors to check bodies.

Diff:
---
 libstdc++-v3/include/bits/mofunc_impl.h            |  2 +-
 .../testsuite/20_util/move_only_function/cons.cc   | 27 ++++++++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/include/bits/mofunc_impl.h b/libstdc++-v3/include/bits/mofunc_impl.h
index 543c6f547b7..968d235f867 100644
--- a/libstdc++-v3/include/bits/mofunc_impl.h
+++ b/libstdc++-v3/include/bits/mofunc_impl.h
@@ -108,7 +108,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	move_only_function(in_place_type_t<_Tp>, initializer_list<_Up> __il,
 			   _Args&&... __args)
 	noexcept(_S_nothrow_init<_Tp, initializer_list<_Up>&, _Args...>())
-	: _Mofunc_base(nullptr), _M_invoke(&_S_invoke<_Tp>)
+	: _M_invoke(&_S_invoke<_Tp>)
 	{
 	  static_assert(is_same_v<decay_t<_Tp>, _Tp>);
 	  _M_init<_Tp>(__il, std::forward<_Args>(__args)...);
diff --git a/libstdc++-v3/testsuite/20_util/move_only_function/cons.cc b/libstdc++-v3/testsuite/20_util/move_only_function/cons.cc
index 0992f107003..d8a0a4ab2b0 100644
--- a/libstdc++-v3/testsuite/20_util/move_only_function/cons.cc
+++ b/libstdc++-v3/testsuite/20_util/move_only_function/cons.cc
@@ -96,3 +96,30 @@ static_assert( ! is_nothrow_constructible_v<move_only_function<void() noexcept>,
 					    in_place_type_t<H>, int> );
 static_assert( is_nothrow_constructible_v<move_only_function<void() noexcept>,
 					  in_place_type_t<H>, int, int> );
+
+struct I {
+  I(int, const char*);
+  I(std::initializer_list<char>);
+  int operator()() const noexcept;
+};
+
+static_assert( is_constructible_v<move_only_function<void()>,
+				  std::in_place_type_t<I>,
+				  int, const char*> );
+static_assert( is_constructible_v<move_only_function<void()>,
+				  std::in_place_type_t<I>,
+				  std::initializer_list<char>> );
+
+void
+test_instantiation()
+{
+  // Instantiate the constructor bodies
+  move_only_function<void()> f0;
+  move_only_function<void()> f1(nullptr);
+  move_only_function<void()> f2( I(1, "two") );
+  move_only_function<void()> f3(std::in_place_type<I>, 3, "four");
+  move_only_function<void()> f4(std::in_place_type<I>, // PR libstdc++/102825
+				{ 'P', 'R', '1', '0', '2', '8', '2', '5'});
+  auto f5 = std::move(f4);
+  f4 = std::move(f5);
+}


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

only message in thread, other threads:[~2021-10-19 10:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-19 10:50 [gcc r12-4500] libstdc++: Fix mem-initializer in std::move_only_function [PR102825] 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).