re PR libstdc++/80034 (unqualified calls to std::distance in std::list::sort)

PR libstdc++/80034
* include/bits/list.tcc (merge(list&&)): Use const for the size_t
in the catch-block.
(merge(list&&, _StrictWeakOrdering)): Likewise.
* testsuite/23_containers/list/operations/80034.cc: New.

From-SVN: r246107
This commit is contained in:
Ville Voutilainen 2017-03-13 21:41:50 +02:00 committed by Ville Voutilainen
parent a00a486562
commit 648c989484
3 changed files with 42 additions and 2 deletions

View File

@ -1,3 +1,11 @@
2017-03-13 Ville Voutilainen <ville.voutilainen@gmail.com>
PR libstdc++/80034
* include/bits/list.tcc (merge(list&&)): Use const for the size_t
in the catch-block.
(merge(list&&, _StrictWeakOrdering)): Likewise.
* testsuite/23_containers/list/operations/80034.cc: New.
2017-03-13 Ville Voutilainen <ville.voutilainen@gmail.com>
Implement LWG 2806, Base class of bad_optional_access.

View File

@ -405,7 +405,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
__catch(...)
{
size_t __dist = std::distance(__first2, __last2);
const size_t __dist = std::distance(__first2, __last2);
this->_M_inc_size(__orig_size - __dist);
__x._M_set_size(__dist);
__throw_exception_again;
@ -453,7 +453,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
__catch(...)
{
size_t __dist = std::distance(__first2, __last2);
const size_t __dist = std::distance(__first2, __last2);
this->_M_inc_size(__orig_size - __dist);
__x._M_set_size(__dist);
__throw_exception_again;

View File

@ -0,0 +1,32 @@
// { dg-do compile }
// Copyright (C) 2017 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 <list>
namespace X {
struct Y { };
bool operator<(Y, Y) { return false; }
template<typename T>
void distance(T, T) { }
}
int main()
{
std::list<X::Y> l;
l.sort();
}