public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc r12-4500] libstdc++: Fix mem-initializer in std::move_only_function [PR102825]
Date: Tue, 19 Oct 2021 10:50:51 +0000 (GMT)	[thread overview]
Message-ID: <20211019105051.6DF553858D39@sourceware.org> (raw)

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);
+}


                 reply	other threads:[~2021-10-19 10:50 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211019105051.6DF553858D39@sourceware.org \
    --to=redi@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    --cc=libstdc++-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).