This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
empty range in pop_heap
- From: Markus Trippelsdorf <markus at trippelsdorf dot de>
- To: libstdc++ at gcc dot gnu dot org
- Date: Sat, 12 Nov 2011 14:53:24 +0100
- Subject: empty range in pop_heap
Please consider:
markus@x4 ~ % cat heap1.cpp
#include <algorithm>
#include <vector>
#include <cassert>
using namespace std;
int
main (void)
{
int d[4] = { 1, 2, 3, 4 };
vector < int >v (d, d + 4);
make_heap (v.begin (), v.end ());
assert (is_heap (v.begin (), v.begin ()));
pop_heap (v.begin (), v.begin ());
}
markus@x4 ~ % c++ -std=c++11 -O2 heap1.cpp
markus@x4 ~ % ./a.out
*** glibc detected *** ./a.out: double free or corruption (out): 0x0000000000b3a010 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x772b6)[0x7f25b415d2b6]
./a.out[0x4007ee]
/lib64/libc.so.6(__libc_start_main+0xed)[0x7f25b410735d]
./a.out[0x4005a9]
======= Memory map: ========
...
[1] 22017 abort ./a.out
markus@x4 ~ % c++ -std=c++11 -D_GLIBCXX_DEBUG -O2 heap1.cpp
markus@x4 ~ % ./a.out
/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.0/include/g++-v4/debug/safe_iterator.h:279:
error: attempt to decrement a dereferenceable (start-of-sequence)
iterator.
Objects involved in the operation:
iterator "this" @ 0x0x7fff53847990 {
type = N11__gnu_debug14_Safe_iteratorIN9__gnu_cxx17__normal_iteratorIPiNSt9__cxx19986vectorIiSaIiEEEEENSt7__debug6vectorIiS6_EEEE (mutable iterator);
state = dereferenceable (start-of-sequence);
references sequence with type `NSt7__debug6vectorIiSaIiEEE' @ 0x0x7fff53847990
}
[1] 22143 abort ./a.out
Shouldn't "pop_heap (v.begin (), v.begin ())" be allowed?
--
Markus