This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch] libstdc++/36338


Hi,

this is the patch I finished testing in debug-mode too on x86_64-linux. Seems rather straightforward to me, but It would be nice if Chris could double check it (sorry, but I'm still scared by some trickeries with iterators), I'll wait a few hours before committing, mainline only, in any case.

Paolo.

///////////////////

2008-05-29  Paolo Carlini  <paolo.carlini@oracle.com>
	    Chris Jefferson  <chris@bubblescope.net>

	PR libstdc++/36338
	* include/bits/stl_heap.h (sort_heap): Use __pop_heap directly.
	(pop_heap): Slightly tweak.
Index: include/bits/stl_heap.h
===================================================================
--- include/bits/stl_heap.h	(revision 136158)
+++ include/bits/stl_heap.h	(working copy)
@@ -1,6 +1,6 @@
 // Heap implementation -*- C++ -*-
 
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
 // Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -285,7 +285,8 @@
       __glibcxx_requires_valid_range(__first, __last);
       __glibcxx_requires_heap(__first, __last);
 
-      std::__pop_heap(__first, __last - 1, __last - 1);
+      --__last;
+      std::__pop_heap(__first, __last, __last);
     }
 
   template<typename _RandomAccessIterator, typename _Distance,
@@ -355,7 +356,8 @@
       __glibcxx_requires_valid_range(__first, __last);
       __glibcxx_requires_heap_pred(__first, __last, __comp);
 
-      std::__pop_heap(__first, __last - 1, __last - 1, __comp);
+      --__last;
+      std::__pop_heap(__first, __last, __last, __comp);
     }
 
   /**
@@ -458,7 +460,10 @@
       __glibcxx_requires_heap(__first, __last);
 
       while (__last - __first > 1)
-	std::pop_heap(__first, _RandomAccessIterator(__last--));
+	{
+	  --__last;
+	  std::__pop_heap(__first, __last, __last);
+	}
     }
 
   /**
@@ -483,7 +488,10 @@
       __glibcxx_requires_heap_pred(__first, __last, __comp);
 
       while (__last - __first > 1)
-	std::pop_heap(__first, _RandomAccessIterator(__last--), __comp);
+	{
+	  --__last;
+	  std::__pop_heap(__first, __last, __last, __comp);
+	}
     }
 
 #ifdef __GXX_EXPERIMENTAL_CXX0X__

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]