From e13afbace17d25acdad40cc4649b51d28ec42364 Mon Sep 17 00:00:00 2001 From: Markus Trippelsdorf Date: Sun, 4 Dec 2011 13:21:53 +0000 Subject: [PATCH] stl_heap.h (pop_heap): Check for non-empty range in overload taking a predicate. * include/bits/stl_heap.h (pop_heap): Check for non-empty range in overload taking a predicate. * testsuite/25_algorithms/pop_heap/empty2_neg.cc: New. Co-Authored-By: Jonathan Wakely From-SVN: r181987 --- libstdc++-v3/ChangeLog | 7 ++++ libstdc++-v3/include/bits/stl_heap.h | 1 + .../25_algorithms/pop_heap/empty2_neg.cc | 38 +++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 libstdc++-v3/testsuite/25_algorithms/pop_heap/empty2_neg.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index c070e89d432..6751abbdfae 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,10 @@ +2011-12-04 Markus Trippelsdorf + Jonathan Wakely + + * include/bits/stl_heap.h (pop_heap): Check for non-empty range in + overload taking a predicate. + * testsuite/25_algorithms/pop_heap/empty2_neg.cc: New. + 2011-12-03 Jonathan Wakely * include/debug/macros.h (__glibcxx_check_non_empty_range): Define. diff --git a/libstdc++-v3/include/bits/stl_heap.h b/libstdc++-v3/include/bits/stl_heap.h index ed7750c2fa7..f185610d9e0 100644 --- a/libstdc++-v3/include/bits/stl_heap.h +++ b/libstdc++-v3/include/bits/stl_heap.h @@ -361,6 +361,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept< _RandomAccessIterator>) __glibcxx_requires_valid_range(__first, __last); + __glibcxx_requires_non_empty_range(__first, __last); __glibcxx_requires_heap_pred(__first, __last, __comp); --__last; diff --git a/libstdc++-v3/testsuite/25_algorithms/pop_heap/empty2_neg.cc b/libstdc++-v3/testsuite/25_algorithms/pop_heap/empty2_neg.cc new file mode 100644 index 00000000000..022a1b29af5 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/pop_heap/empty2_neg.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2011 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 Pred 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 +// . + +// 25.3.6 Heap operations [lib.alg.heap.operations] + +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include +#include + +void +test01() +{ + int i = 0; + std::pop_heap(&i, &i, std::less()); +} + +int +main() +{ + test01(); + return 0; +}