From patchwork Sun Dec 4 09:37:20 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Trippelsdorf X-Patchwork-Id: 129130 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id B751E1007D4 for ; Sun, 4 Dec 2011 20:37:42 +1100 (EST) Received: (qmail 13395 invoked by alias); 4 Dec 2011 09:37:39 -0000 Received: (qmail 13384 invoked by uid 22791); 4 Dec 2011 09:37:38 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from ud10.udmedia.de (HELO mail.ud10.udmedia.de) (194.117.254.50) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 04 Dec 2011 09:37:22 +0000 Received: (qmail 10951 invoked from network); 4 Dec 2011 10:37:20 +0100 Received: from unknown (HELO x4.trippels.de) (ud10?360p3@91.64.56.160) by mail.ud10.udmedia.de with ESMTPSA (DHE-RSA-AES256-SHA encrypted, authenticated); 4 Dec 2011 10:37:20 +0100 Date: Sun, 4 Dec 2011 10:37:20 +0100 From: Markus Trippelsdorf To: Jonathan Wakely Cc: libstdc++@gcc.gnu.org, gcc-patches Subject: Re: empty range in pop_heap Message-ID: <20111204093720.GA17045@x4.trippels.de> References: <20111112135324.GA23388@x4.trippels.de> <20111112141241.GB23388@x4.trippels.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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);