From 7b3318c41e6165140e59e026988d1f6e27d01a2a Mon Sep 17 00:00:00 2001 From: Ville Voutilainen Date: Tue, 5 Apr 2016 14:31:30 +0300 Subject: [PATCH] re PR libstdc++/70437 (Instantiation loop with pair and is_constructible) PR libstdc++/70437 * include/bits/stl_pair.h (_ConstructiblePair, _ImplicitlyConvertiblePair, _MoveConstructiblePair, _ImplicitlyMoveConvertiblePair): Add shortcut conditions for same-type cases. * testsuite/20_util/pair/70437.cc: New. From-SVN: r234743 --- libstdc++-v3/ChangeLog | 9 +++++ libstdc++-v3/include/bits/stl_pair.h | 35 +++++++++++++----- libstdc++-v3/testsuite/20_util/pair/70437.cc | 37 ++++++++++++++++++++ 3 files changed, 73 insertions(+), 8 deletions(-) create mode 100644 libstdc++-v3/testsuite/20_util/pair/70437.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 4e6db2ab3db..2977bd0938a 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,12 @@ +2016-04-05 Ville Voutilainen + + PR libstdc++/70437 + * include/bits/stl_pair.h (_ConstructiblePair, + _ImplicitlyConvertiblePair, _MoveConstructiblePair, + _ImplicitlyMoveConvertiblePair): Add shortcut conditions + for same-type cases. + * testsuite/20_util/pair/70437.cc: New. + 2016-03-24 Jonathan Wakely PR libstdc++/69945 diff --git a/libstdc++-v3/include/bits/stl_pair.h b/libstdc++-v3/include/bits/stl_pair.h index 7057030d9d7..37ee5cc4053 100644 --- a/libstdc++-v3/include/bits/stl_pair.h +++ b/libstdc++-v3/include/bits/stl_pair.h @@ -87,32 +87,51 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Concept utility functions, reused in conditionally-explicit // constructors. + // See PR 70437, don't look at is_constructible or + // is_convertible if the decayed types are the same to + // avoid querying those properties for incomplete types. template constexpr bool _ConstructiblePair() { - return __and_, - is_constructible<_T2, const _U2&>>::value; + return __and_<__or_::type, + typename decay<_U1>::type>, + is_constructible<_T1, const _U1&>>, + __or_::type, + typename decay<_U2>::type>, + is_constructible<_T2, const _U2&>>>::value; } template constexpr bool _ImplicitlyConvertiblePair() { - return __and_, - is_convertible>::value; + return __and_<__or_::type, + typename decay<_U1>::type>, + is_convertible>, + __or_::type, + typename decay<_U2>::type>, + is_convertible>>::value; } template constexpr bool _MoveConstructiblePair() { - return __and_, - is_constructible<_T2, _U2&&>>::value; + return __and_<__or_::type, + typename decay<_U1>::type>, + is_constructible<_T1, _U1&&>>, + __or_::type, + typename decay<_U2>::type>, + is_constructible<_T2, _U2&&>>>::value; } template constexpr bool _ImplicitlyMoveConvertiblePair() { - return __and_, - is_convertible<_U2&&, _T2>>::value; + return __and_<__or_::type, + typename decay<_U1>::type>, + is_convertible<_U1&&, _T1>>, + __or_::type, + typename decay<_U2>::type>, + is_convertible<_U2&&, _T2>>>::value; } diff --git a/libstdc++-v3/testsuite/20_util/pair/70437.cc b/libstdc++-v3/testsuite/20_util/pair/70437.cc new file mode 100644 index 00000000000..37e6fb7ec1a --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/pair/70437.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2016 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 +// . + +#include + +template struct B; + +template struct A +{ + A(A&&) = default; + A(const B &); +}; + +template struct B +{ + std::pair,int> a; + B(B&&) = default; +}; + +bool b = std::is_move_constructible >::value;