diff options
author | François Dumont <fdumont@gcc.gnu.org> | 2015-08-25 20:27:03 +0000 |
---|---|---|
committer | François Dumont <fdumont@gcc.gnu.org> | 2015-08-25 20:27:03 +0000 |
commit | 630a286ab6c4514c4cc4ff154cf68bf150f164f2 (patch) | |
tree | 96fcb89278ebb65691df3bfc9fedfca4d75d2f04 /libstdc++-v3/testsuite/25_algorithms/partial_sort_copy | |
parent | 9376dd63e6a2d94823f6faf8212c9f37bef5a656 (diff) | |
download | gcc-630a286ab6c4514c4cc4ff154cf68bf150f164f2.tar.gz |
re PR libstdc++/60519 (Debug mode should check comparators for irreflexivity)
2015-08-24 François Dumont <fdumont@gcc.gnu.org>
PR libstdc++/60519
* include/debug/formatter.h (_Debug_msg_id::__msg_irreflexive_ordering):
New enum entry.
* include/debug/functions.h (_Irreflexive_checker): New.
(__is_irreflexive, __is_irreflexive_pred): New.
* include/debug/macros.h
(__glibcxx_check_irreflexive, __glibcxx_check_irreflexive_pred): New
macros.
(__glibcxx_check_irreflexive2, __glibcxx_check_irreflexive_pred2): New
macros limited to post-C++11 mode.
* include/debug/debug.h
(__glibcxx_requires_irreflexive, __glibcxx_requires_irreflexive_pred):
New macros, use latter.
(__glibcxx_requires_irreflexive2, __glibcxx_requires_irreflexive_pred2):
Likewise.
* include/bits/stl_algo.h
(partial_sort_copy): Add irreflexive debug check.
(partial_sort_copy): Likewise.
(lower_bound): Likewise.
(upper_bound): Likewise.
(equal_range): Likewise.
(binary_search): Likewise.
(inplace_merge): Likewise.
(includes): Likewise.
(next_permutation): Likewise.
(prev_permutation): Likewise.
(is_sorted_until): Likewise.
(minmax_element): Likewise.
(partial_sort): Likewise.
(nth_element): Likewise.
(sort): Likewise.
(merge): Likewise.
(stable_sort): Likewise.
(set_union): Likewise.
(set_intersection): Likewise.
(set_difference): Likewise.
(set_symmetric_difference): Likewise.
(min_element): Likewise.
(max_element): Likewise.
* include/bits/stl_algobase.h
(lower_bound): Likewise.
(lexicographical_compare): Likewise.
* include/bits/stl_heap.h
(push_heap): Likewise.
(pop_heap): Likewise.
(make_heap): Likewise.
(sort_heap): Likewise.
(is_heap_until): Likewise.
* testsuite/25_algorithms/lexicographical_compare/debug/
irreflexive_neg.cc: New.
* testsuite/25_algorithms/lower_bound/debug/irreflexive.cc: New.
* testsuite/25_algorithms/partial_sort_copy/debug/irreflexive_neg.cc:
New.
From-SVN: r227189
Diffstat (limited to 'libstdc++-v3/testsuite/25_algorithms/partial_sort_copy')
-rw-r--r-- | libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/debug/irreflexive_neg.cc | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/debug/irreflexive_neg.cc b/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/debug/irreflexive_neg.cc new file mode 100644 index 00000000000..0218a269e19 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/debug/irreflexive_neg.cc @@ -0,0 +1,43 @@ +// 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-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include <algorithm> + +bool +bad_lower(int lhs, int rhs) +{ + if (lhs == 0) + return true; + + return lhs < rhs; +} + +void test01() +{ + int ins[] { 0, 1, 2, 3 }; + int outs[] { 9, 9 }; + std::partial_sort_copy(ins, ins + 4, outs, outs + 2, bad_lower); +} + +int main() +{ + test01(); + return 0; +} |