469,964 Members | 1,712 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,964 developers. It's quick & easy.

stl vector pop_back() crash

Hi. For some reason I am getting a crash on pop_back() and Im not sure
why.

sorry I cant post the whole code because the vector is used in a bunch
of places.

i have a

vector<bool> complete;

right before i pop back, i set the last element to overwrite on of the
ones in the array.

complete[j] = complete[complete.size()-1];
complete.pop_back();

the crash looks like:
unhandled exception: 0xC00000005 Access Violation reading 0x203f5a34

the size of complete before it crashes is 32, so it is not empty.

the code it crashes on is:
operator bool() const
{ // test if bit is set
return ((*_Getptr() & _Mask()) != 0);
}

at:

std::vector<bool,std::allocator<bool> >::reference::operator bool()
Line 1030 + 0x12 C++

std::vector<bool,std::allocator<bool> >::reference::operator=() Line
1006 +0x8 C++

std::_Copy_opt<std::vector<bool,std::allocator<boo l>::iterator,std::vector<bool,std::allocator<bool> ::iterator>(std::vector<bool,std::allocator<bool>: :iterator_First={...},std::vector<bool,std::alloca tor<bool>::iterator_Last={...},std::vector<bool,st d::allocator<bool>>::iterator_Dest={...},std::_Non scalar_ptr_iterator_tag__formal={...})
Line 1022 + 0x26 C++

std::copy<std::vector<bool,std::allocator<bool>::i terator,std::vector<bool,std::allocator<bool>::ite rator>(std::vector<bool,std::allocator<bool>::iter ator_First={...},std::vector<bool,std::allocator<b ool>::iterator_Last={...},std::vector<bool,std::al locator<bool>>::iterator_Dest={...})
Line 1040 + 0x3e C++

std::vector<bool,std::allocator<bool>::erase(std:: vector<bool,std::allocator<bool>::iterator_Where={ ...})
Line 1562 + 0x42 C++

std::vector<bool,std::allocator<bool> >::pop_back() Line 1483 C++

If anyone has experenced anything like this before, or has some idea
what might be causing the crash, that would be great. thanks!

oliver

Jul 23 '05 #1
2 2906
laniik wrote:
[vector<bool> problem redacted]


I seem to recall that there was some sort of problem with the MS
implementation of vector<bool>. I know Dr. Plaugher reads this group.

What version of VC are you using?
Jul 23 '05 #2
VC .net 2003 version 7.1.3008

thanks

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Stefan Höhne | last post: by
7 posts views Thread by William Payne | last post: by
10 posts views Thread by Bob | last post: by
11 posts views Thread by eeykay | last post: by
3 posts views Thread by Jeff | last post: by
3 posts views Thread by Sarath | last post: by
reply views Thread by James Kanze | last post: by
1 post views Thread by rainxy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.