empty range in pop_heap
Jonathan Wakely
jwakely.gcc@gmail.com
Sun Dec 4 13:31:00 GMT 2011
On 4 December 2011 09:37, Markus Trippelsdorf wrote:
>
> You forgot to change the second one with the comparison functor.
Doh! Thanks, fixed now.
* 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.
Tested x86-64-linux, committed to trunk.
-------------- next part --------------
Index: include/bits/stl_heap.h
===================================================================
--- include/bits/stl_heap.h (revision 181986)
+++ include/bits/stl_heap.h (revision 181987)
@@ -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;
Index: testsuite/25_algorithms/pop_heap/empty2_neg.cc
===================================================================
--- testsuite/25_algorithms/pop_heap/empty2_neg.cc (revision 0)
+++ testsuite/25_algorithms/pop_heap/empty2_neg.cc (revision 181987)
@@ -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
+// <http://www.gnu.org/licenses/>.
+
+// 25.3.6 Heap operations [lib.alg.heap.operations]
+
+// { dg-require-debug-mode "" }
+// { dg-do run { xfail *-*-* } }
+
+#include <algorithm>
+#include <functional>
+
+void
+test01()
+{
+ int i = 0;
+ std::pop_heap(&i, &i, std::less<int>());
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
More information about the Libstdc++
mailing list