aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2014-05-13 12:18:01 +0100
committerJonathan Wakely <redi@gcc.gnu.org>2014-05-13 12:18:01 +0100
commit75e75a087d4aca27ced05a540a858358301eee92 (patch)
treebc29694690e0bf0551f94ff7a9cb3edbb5500ee1 /libstdc++-v3
parent6b77934ee0a2d22031db48fe6ce0f42154ac21dc (diff)
downloadgcc-75e75a087d4aca27ced05a540a858358301eee92.zip
gcc-75e75a087d4aca27ced05a540a858358301eee92.tar.gz
gcc-75e75a087d4aca27ced05a540a858358301eee92.tar.bz2
re PR libstdc++/60497 (unique_ptr<T> tries to complete its type T even though it's not required to be a complete type)
PR libstdc++/60497 * include/std/tuple (get, __tuple_compare): Qualify more calls to prevent ADL. Cast comparison results to bool. * testsuite/20_util/tuple/60497.cc: Test accessing rvalues. * testsuite/20_util/tuple/comparison_operators/overloaded.cc: New. From-SVN: r210366
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog8
-rw-r--r--libstdc++-v3/include/std/tuple12
-rw-r--r--libstdc++-v3/testsuite/20_util/tuple/60497.cc6
-rw-r--r--libstdc++-v3/testsuite/20_util/tuple/comparison_operators/overloaded.cc52
4 files changed, 72 insertions, 6 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 415a879..9a776d1 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,11 @@
+2014-05-13 Jonathan Wakely <jwakely@redhat.com>
+
+ PR libstdc++/60497
+ * include/std/tuple (get, __tuple_compare): Qualify more calls to
+ prevent ADL. Cast comparison results to bool.
+ * testsuite/20_util/tuple/60497.cc: Test accessing rvalues.
+ * testsuite/20_util/tuple/comparison_operators/overloaded.cc: New.
+
2014-05-09 Jonathan Wakely <jwakely@redhat.com>
* config/abi/pre/gnu.ver (GLIBCXX_3.4.20): Correct regex_error export.
diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple
index 03d87d7..5e8766c 100644
--- a/libstdc++-v3/include/std/tuple
+++ b/libstdc++-v3/include/std/tuple
@@ -775,7 +775,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>::type
get(tuple<_Elements...>&& __t) noexcept
{ return std::forward<typename tuple_element<__i,
- tuple<_Elements...>>::type&&>(get<__i>(__t)); }
+ tuple<_Elements...>>::type&&>(std::get<__i>(__t)); }
#if __cplusplus > 201103L
template<typename _Head, size_t __i, typename... _Tail>
@@ -815,16 +815,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static constexpr bool
__eq(const _Tp& __t, const _Up& __u)
{
- return (get<__i>(__t) == get<__i>(__u) &&
- __tuple_compare<0, __i + 1, __j, _Tp, _Up>::__eq(__t, __u));
+ return bool(std::get<__i>(__t) == std::get<__i>(__u))
+ && __tuple_compare<0, __i + 1, __j, _Tp, _Up>::__eq(__t, __u);
}
static constexpr bool
__less(const _Tp& __t, const _Up& __u)
{
- return ((get<__i>(__t) < get<__i>(__u))
- || !(get<__i>(__u) < get<__i>(__t)) &&
- __tuple_compare<0, __i + 1, __j, _Tp, _Up>::__less(__t, __u));
+ return bool(std::get<__i>(__t) < std::get<__i>(__u))
+ || !bool(std::get<__i>(__u) < std::get<__i>(__t))
+ && __tuple_compare<0, __i + 1, __j, _Tp, _Up>::__less(__t, __u);
}
};
diff --git a/libstdc++-v3/testsuite/20_util/tuple/60497.cc b/libstdc++-v3/testsuite/20_util/tuple/60497.cc
index 76d4223..40d053b 100644
--- a/libstdc++-v3/testsuite/20_util/tuple/60497.cc
+++ b/libstdc++-v3/testsuite/20_util/tuple/60497.cc
@@ -35,3 +35,9 @@ auto a = std::get<0>(t);
auto b = std::get<0>(ct);
auto c = std::get<element_type>(t);
auto d = std::get<element_type>(ct);
+
+// same again for rvalues
+auto e = std::get<0>(std::move(t));
+auto f = std::get<0>(std::move(ct));
+auto g = std::get<element_type>(std::move(t));
+auto h = std::get<element_type>(std::move(ct));
diff --git a/libstdc++-v3/testsuite/20_util/tuple/comparison_operators/overloaded.cc b/libstdc++-v3/testsuite/20_util/tuple/comparison_operators/overloaded.cc
new file mode 100644
index 0000000..0a343ae
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/tuple/comparison_operators/overloaded.cc
@@ -0,0 +1,52 @@
+// { dg-options "-std=gnu++11" }
+// { dg-do compile }
+
+// Copyright (C) 2014 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/>.
+
+#include <tuple>
+
+// A type that is contextually convertible to bool but cannot be used with
+// the usual logical operators, and/or/not.
+struct TwistedLogic {
+ bool value;
+
+ explicit operator bool() const noexcept { return value; }
+};
+
+template<typename T>
+bool operator&&(const T&, TwistedLogic) = delete;
+
+template<typename T>
+bool operator&&(TwistedLogic, const T&) = delete;
+
+template<typename T>
+bool operator||(const T&, TwistedLogic) = delete;
+
+template<typename T>
+bool operator||(TwistedLogic, const T&) = delete;
+
+bool operator!(TwistedLogic) noexcept = delete;
+
+struct Compares {};
+
+TwistedLogic operator==(const Compares&, const Compares&) { return {true}; }
+TwistedLogic operator<(const Compares&, const Compares&) { return {false}; }
+
+auto a = std::make_tuple(nullptr, Compares{}, 2, 'U');
+auto b = a == a;
+auto c = a < a;