diff options
author | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-10-01 12:34:04 +0000 |
---|---|---|
committer | redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-10-01 12:34:04 +0000 |
commit | 9b574f1ece055ed1ad5ba32bc9ce570e9d9e2b29 (patch) | |
tree | 8122d9235d871ae80b24764f5092204a5d8dc966 /libstdc++-v3/testsuite/25_algorithms | |
parent | 2a3c6015d629ceee979449dda033393056a7eb55 (diff) | |
download | ppe42-gcc-9b574f1ece055ed1ad5ba32bc9ce570e9d9e2b29.tar.gz ppe42-gcc-9b574f1ece055ed1ad5ba32bc9ce570e9d9e2b29.zip |
PR libstdc++/59603
* include/bits/stl_algo.h (random_shuffle): Prevent self-swapping.
* testsuite/25_algorithms/random_shuffle/59603.cc: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_9-branch@215754 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite/25_algorithms')
-rw-r--r-- | libstdc++-v3/testsuite/25_algorithms/random_shuffle/59603.cc | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/25_algorithms/random_shuffle/59603.cc b/libstdc++-v3/testsuite/25_algorithms/random_shuffle/59603.cc new file mode 100644 index 00000000000..7b179ac19a0 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/random_shuffle/59603.cc @@ -0,0 +1,34 @@ +// Copyright (C) 2014 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++11" } +// { dg-require-debug-mode "" } + +// libstdc++/59603 + +#include <algorithm> +#include <vector> + +struct C { + std::vector<int> v; + C (int a) : v{a} {}; +}; + +int main () { + std::vector<C> cs { {1}, {2}, {3}, {4} }; + std::random_shuffle(cs.begin(), cs.end()); +} |