diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index d9d4f0e64e0fbf557968c080aef302010fa874f1..ac4df1ad515ed5caad6dfbacebd60966cd0f8660 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,10 @@ +2018-10-31 Jonathan Wakely <jwakely@redhat.com> + + PR libstdc++/87822 + * include/bits/stl_pair.h (__pair_base): Change to class template. + (pair): Make base class type depend on template parameters. + * testsuite/20_util/pair/87822.cc: New test. + 2018-10-30 Marek Polacek <polacek@redhat.com> Implement P0892R2, explicit(bool). diff --git a/libstdc++-v3/include/bits/stl_pair.h b/libstdc++-v3/include/bits/stl_pair.h index ea8bd981559bdcfd8b130138a874a492541b26b8..48af2b02ef975913017d85294cf97a5319e51062 100644 --- a/libstdc++-v3/include/bits/stl_pair.h +++ b/libstdc++-v3/include/bits/stl_pair.h @@ -187,7 +187,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; #endif // C++11 - class __pair_base + template<typename _U1, typename _U2> class __pair_base { #if __cplusplus >= 201103L template<typename _T1, typename _T2> friend struct pair; @@ -206,7 +206,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION */ template<typename _T1, typename _T2> struct pair - : private __pair_base + : private __pair_base<_T1, _T2> { typedef _T1 first_type; /// @c first_type is the first bound type typedef _T2 second_type; /// @c second_type is the second bound type diff --git a/libstdc++-v3/testsuite/20_util/pair/87822.cc b/libstdc++-v3/testsuite/20_util/pair/87822.cc new file mode 100644 index 0000000000000000000000000000000000000000..cd099d6f9f9fe0674a570ed851e2990f1733fde5 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/pair/87822.cc @@ -0,0 +1,47 @@ +// Copyright (C) 2018 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 <utility> +#include <testsuite_hooks.h> + +void +test01() +{ + std::pair<std::pair<int, int>, int> p; +#if __cplusplus >= 201103L + static_assert(sizeof(p) == (3 * sizeof(int)), "PR libstdc++/87822"); +#endif + VERIFY( (void*)&p == (void*)&p.first ); +} + +struct empty { }; + +void +test02() +{ + std::pair<std::pair<empty, empty>, empty> p; +#if __cplusplus >= 201103L + static_assert(sizeof(p) == (3 * sizeof(empty)), "PR libstdc++/87822"); +#endif + VERIFY( (void*)&p == (void*)&p.first ); +} + +int main() +{ + test01(); + test02(); +}