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
This commit is contained in:
Jonathan Wakely 2014-05-13 12:18:01 +01:00 committed by Jonathan Wakely
parent 6b77934ee0
commit 75e75a087d
4 changed files with 72 additions and 6 deletions

View File

@ -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.

View File

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

View File

@ -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));

View File

@ -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;