diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2015-01-18 16:31:06 +0000 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2015-01-18 16:31:06 +0000 |
commit | 257024e31e297085e9f1d0c414f3a9cada93f300 (patch) | |
tree | 0f8bbf389dd1b21a4b8270eba351c1303bcf2c1f | |
parent | 8fc4dc4adc207d36dce5e6820a1b95d6c83149db (diff) | |
download | gcc-257024e31e297085e9f1d0c414f3a9cada93f300.zip gcc-257024e31e297085e9f1d0c414f3a9cada93f300.tar.gz gcc-257024e31e297085e9f1d0c414f3a9cada93f300.tar.bz2 |
re PR libstdc++/64646 (New overloads of std::is_permutation dereference past-the-end iterator)
PR libstdc++/64646
* include/bits/stl_algo.h (__is_permutation): Also test for reaching
end of the second range.
* testsuite/25_algorithms/is_permutation/64646.cc: New.
From-SVN: r219821
-rw-r--r-- | libstdc++-v3/ChangeLog | 7 | ||||
-rw-r--r-- | libstdc++-v3/include/bits/stl_algo.h | 3 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/25_algorithms/is_permutation/64646.cc | 35 |
3 files changed, 44 insertions, 1 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index b40e940..52f77b8 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,12 @@ 2015-01-18 Jonathan Wakely <jwakely@redhat.com> + PR libstdc++/64646 + * include/bits/stl_algo.h (__is_permutation): Also test for reaching + end of the second range. + * testsuite/25_algorithms/is_permutation/64646.cc: New. + +2015-01-18 Jonathan Wakely <jwakely@redhat.com> + * doc/xml/manual/status_cxx2011.xml: Remove note about offsetof. * doc/html/manual/status.html: Regenerate. diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h index 3325b94..c27c092 100644 --- a/libstdc++-v3/include/bits/stl_algo.h +++ b/libstdc++-v3/include/bits/stl_algo.h @@ -3601,7 +3601,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Efficiently compare identical prefixes: O(N) if sequences // have the same elements in the same order. - for (; __first1 != __last1; ++__first1, ++__first2) + for (; __first1 != __last1 && __first2 != __last2; + ++__first1, ++__first2) if (!__pred(__first1, __first2)) break; diff --git a/libstdc++-v3/testsuite/25_algorithms/is_permutation/64646.cc b/libstdc++-v3/testsuite/25_algorithms/is_permutation/64646.cc new file mode 100644 index 0000000..799a18c --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/is_permutation/64646.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2015 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/>. + +// { dg-options "-std=gnu++14" } + +#include <algorithm> +#include <forward_list> +#include <testsuite_hooks.h> + +void +test01() +{ + std::forward_list<int> l1{0}, l2; + VERIFY( !std::is_permutation(l1.begin(), l1.end(), l2.begin(), l2.end()) ); +} + +int +main() +{ + test01(); +} |