diff options
author | ville <ville@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-03-13 19:41:50 +0000 |
---|---|---|
committer | ville <ville@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-03-13 19:41:50 +0000 |
commit | 0d8185a257cba182fbfa111dce86593373d1e36e (patch) | |
tree | f59ccedbb7a931ecd5f1cb4d3d1b7cb3a83dde31 /libstdc++-v3 | |
parent | 781c10fe49ef4d2b49388a747648d42948e30cc0 (diff) | |
download | gcc-0d8185a257cba182fbfa111dce86593373d1e36e.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@246107 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 8 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/list.tcc | 4 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/23_containers/list/operations/80034.cc | 32 |
3 files changed, 42 insertions, 2 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index c85d6a78d56..544d15549aa 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,13 @@ 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. * include/std/optional (bad_optional_access): Derive from std::exception. diff --git a/libstdc++-v3/include/bits/list.tcc b/libstdc++-v3/include/bits/list.tcc index 9623a139a70..fcb8353e09f 100644 --- a/libstdc++-v3/include/bits/list.tcc +++ b/libstdc++-v3/include/bits/list.tcc @@ -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; diff --git a/libstdc++-v3/testsuite/23_containers/list/operations/80034.cc b/libstdc++-v3/testsuite/23_containers/list/operations/80034.cc new file mode 100644 index 00000000000..5c3decd9dff --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/operations/80034.cc @@ -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(); +} |