public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r9-9639] libstdc++: Fix std::any constraints [PR101034]
@ 2021-07-22 21:29 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2021-07-22 21:29 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:df0438f1493c4fe1a7380519d9013148618d9782

commit r9-9639-gdf0438f1493c4fe1a7380519d9013148618d9782
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Jun 14 14:18:33 2021 +0100

    libstdc++: Fix std::any constraints [PR101034]
    
            PR libstdc++/101034
    
    libstdc++-v3/ChangeLog:
    
            * include/std/any (any(in_place_t<T>, initializer_list<U>, A&&...))
            (any::emplace<T>(initializer_list<U>, A&&...)): Fix constraint
            to use lvalue.
            * testsuite/20_util/any/cons/101034.cc: New test.
    
    (cherry picked from commit 14f26c75d255ef05b706a12d25b003da8a2f5b45)

Diff:
---
 libstdc++-v3/include/std/any                      |  4 ++--
 libstdc++-v3/testsuite/20_util/any/cons/101034.cc | 11 +++++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/include/std/any b/libstdc++-v3/include/std/any
index 796949c7d4a..4957144342c 100644
--- a/libstdc++-v3/include/std/any
+++ b/libstdc++-v3/include/std/any
@@ -205,7 +205,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     /// the contained object.
     template <typename _Tp, typename _Up, typename... _Args,
 	      typename _VTp = decay_t<_Tp>, typename _Mgr = _Manager<_VTp>,
-	      __any_constructible_t<_VTp, initializer_list<_Up>,
+	      __any_constructible_t<_VTp, initializer_list<_Up>&,
 				    _Args&&...> = false>
       explicit
       any(in_place_type_t<_Tp>, initializer_list<_Up> __il, _Args&&... __args)
@@ -271,7 +271,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     /// Emplace with an object created from @p __il and @p __args as
     /// the contained object.
     template <typename _Tp, typename _Up, typename... _Args>
-      __emplace_t<decay_t<_Tp>, initializer_list<_Up>, _Args&&...>
+      __emplace_t<decay_t<_Tp>, initializer_list<_Up>&, _Args&&...>
       emplace(initializer_list<_Up> __il, _Args&&... __args)
       {
 	using _VTp = decay_t<_Tp>;
diff --git a/libstdc++-v3/testsuite/20_util/any/cons/101034.cc b/libstdc++-v3/testsuite/20_util/any/cons/101034.cc
new file mode 100644
index 00000000000..55f550a839e
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/any/cons/101034.cc
@@ -0,0 +1,11 @@
+// { dg-do compile { target c++17 } }
+// PR libstdc++/101034 - wrong constraint in std::any's constructor
+
+#include <any>
+
+struct S {
+  S(std::initializer_list<int>&, int) {}
+};
+
+std::any a(std::in_place_type<S>, {0}, 0);
+S& s = a.emplace<S>({0}, 0);


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

only message in thread, other threads:[~2021-07-22 21:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-22 21:29 [gcc r9-9639] libstdc++: Fix std::any constraints [PR101034] 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).