From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Cc: Ville Voutilainen <ville.voutilainen@gmail.com>,
Patrick Palka <ppalka@redhat.com>
Subject: [PATCH] libstdc++: Add missing std::tuple constructor [PR114147]
Date: Fri, 1 Mar 2024 14:23:32 +0000 [thread overview]
Message-ID: <20240301150915.92103-1-jwakely@redhat.com> (raw)
This fixes a regression on all active branches.
Tested aarch64-linux.
-- >8 --
I caused a regression with commit r10-908 by adding a constraint to the
non-explicit allocator-extended default constructor, but seemingly
forgot to add an explicit overload with the corresponding constraint.
libstdc++-v3/ChangeLog:
PR libstdc++/114147
* include/std/tuple (tuple::tuple(allocator_arg_t, const Alloc&)):
Add missing overload of allocator-extended default constructor.
(tuple<T1,T2>::tuple(allocator_arg_t, const Alloc&)): Likewise.
* testsuite/20_util/tuple/cons/114147.cc: New test.
---
libstdc++-v3/include/std/tuple | 14 ++++++++++++++
.../testsuite/20_util/tuple/cons/114147.cc | 15 +++++++++++++++
2 files changed, 29 insertions(+)
create mode 100644 libstdc++-v3/testsuite/20_util/tuple/cons/114147.cc
diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple
index 9c89c13ab84..3065058e184 100644
--- a/libstdc++-v3/include/std/tuple
+++ b/libstdc++-v3/include/std/tuple
@@ -1550,6 +1550,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
tuple(allocator_arg_t __tag, const _Alloc& __a)
: _Inherited(__tag, __a) { }
+ template<typename _Alloc,
+ _ExplicitDefaultCtor<is_object<_Alloc>::value> = false>
+ _GLIBCXX20_CONSTEXPR
+ explicit
+ tuple(allocator_arg_t __tag, const _Alloc& __a)
+ : _Inherited(__tag, __a) { }
+
template<typename _Alloc, bool _NotEmpty = (sizeof...(_Elements) >= 1),
_ImplicitCtor<_NotEmpty, const _Elements&...> = true>
_GLIBCXX20_CONSTEXPR
@@ -2198,6 +2205,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
tuple(allocator_arg_t __tag, const _Alloc& __a)
: _Inherited(__tag, __a) { }
+ template<typename _Alloc,
+ _ExplicitDefaultCtor<is_object<_Alloc>::value, _T1, _T2> = false>
+ _GLIBCXX20_CONSTEXPR
+ explicit
+ tuple(allocator_arg_t __tag, const _Alloc& __a)
+ : _Inherited(__tag, __a) { }
+
template<typename _Alloc, bool _Dummy = true,
_ImplicitCtor<_Dummy, const _T1&, const _T2&> = true>
_GLIBCXX20_CONSTEXPR
diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/114147.cc b/libstdc++-v3/testsuite/20_util/tuple/cons/114147.cc
new file mode 100644
index 00000000000..916e7204964
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/tuple/cons/114147.cc
@@ -0,0 +1,15 @@
+// { dg-do compile { target c++11 } }
+
+// PR libstdc++/114147
+// tuple allocator-extended ctor requires non-explicit default ctor
+
+#include <tuple>
+#include <memory>
+
+struct X { explicit X(); };
+
+std::allocator<int> a;
+std::tuple<X> t0(std::allocator_arg, a);
+std::tuple<int, X> t1(std::allocator_arg, a);
+std::tuple<X, int> t2(std::allocator_arg, a);
+std::tuple<int, X, int> t3(std::allocator_arg, a);
--
2.43.2
reply other threads:[~2024-03-01 15:09 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=20240301150915.92103-1-jwakely@redhat.com \
--to=jwakely@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.org \
--cc=ppalka@redhat.com \
--cc=ville.voutilainen@gmail.com \
/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).