This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: empty range in pop_heap
- From: Markus Trippelsdorf <markus at trippelsdorf dot de>
- To: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- Cc: libstdc++ at gcc dot gnu dot org, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Sun, 4 Dec 2011 10:37:20 +0100
- Subject: Re: empty range in pop_heap
- References: <20111112135324.GA23388@x4.trippels.de> <alpine.DEB.2.02.1111121500550.2466@laptop-mg.saclay.inria.fr> <20111112141241.GB23388@x4.trippels.de> <CAH6eHdRBDutjk49ssY7HR4JgRLGAg1g8i2=Ag_o1=_8pV8ZMLA@mail.gmail.com> <alpine.DEB.2.02.1111121601470.2466@laptop-mg.saclay.inria.fr> <CAH6eHdQS6HSSx1e9pod6HuDavH=DTAnJCSwATXYMZ1t9BsM5eg@mail.gmail.com> <CAH6eHdRkVtpU24M9WVXk4afqkmhZXUs=JWyY5SHycXibMh2NEA@mail.gmail.com>
On 2011.12.03 at 15:35 +0000, Jonathan Wakely wrote:
> On 12 November 2011 15:14, Jonathan Wakely wrote:
> > On 12 November 2011 15:04, Marc Glisse wrote:
> >>
> >> Debug-mode seems to check that first,last is a valid range, is a heap, but
> >> not that it is not empty. Maybe it could?
> >
> > Good idea, thanks. ?I'll change that.
>
> As promised.
>
> * include/debug/macros.h (__glibcxx_check_non_empty_range): Define.
> * include/debug/debug.h (__glibcxx_requires_non_empty_range): Define.
> * include/debug/formatter.h (__msg_non_empty_range): Add.
> * src/debug.cc: Message text for __msg_non_empty_range.
> * include/bits/stl_heap.h (pop_heap): Check for non-empty range.
> * testsuite/25_algorithms/pop_heap/empty_neg.cc: New.
>
> Tested x86_64-linux, committed to trunk.
Thanks Jonathan.
You forgot to change the second one with the comparison functor.
diff --git a/libstdc++-v3/include/bits/stl_heap.h b/libstdc++-v3/include/bits/stl_heap.h
index ed7750c..af62525 100644
--- a/libstdc++-v3/include/bits/stl_heap.h
+++ b/libstdc++-v3/include/bits/stl_heap.h
@@ -360,6 +360,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// concept requirements
__glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
_RandomAccessIterator>)
+ __glibcxx_requires_non_empty_range(__first, __last);
__glibcxx_requires_valid_range(__first, __last);
__glibcxx_requires_heap_pred(__first, __last, __comp);
--
Markus