473,809 Members | 2,769 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_ba ck();

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<boo l,std::allocato r<bool> >::reference::o perator bool()
Line 1030 + 0x12 C++

std::vector<boo l,std::allocato r<bool> >::reference::o perator=() Line
1006 +0x8 C++

std::_Copy_opt< std::vector<boo l,std::allocato r<bool>::iterat or,std::vector< bool,std::alloc ator<bool>::ite rator>(std::vec tor<bool,std::a llocator<bool>: :iterator_First ={...},std::vec tor<bool,std::a llocator<bool>: :iterator_Last= {...},std::vect or<bool,std::al locator<bool>>: :iterator_Dest= {...},std::_Non scalar_ptr_iter ator_tag__forma l={...})
Line 1022 + 0x26 C++

std::copy<std:: vector<bool,std ::allocator<boo l>::iterator,st d::vector<bool, std::allocator< bool>::iterator >(std::vector<b ool,std::alloca tor<bool>::iter ator_First={... },std::vector<b ool,std::alloca tor<bool>::iter ator_Last={...} ,std::vector<bo ol,std::allocat or<bool>>::iter ator_Dest={...} )
Line 1040 + 0x3e C++

std::vector<boo l,std::allocato r<bool>::erase( std::vector<boo l,std::allocato r<bool>::iterat or_Where={...})
Line 1562 + 0x42 C++

std::vector<boo l,std::allocato r<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 3193
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
7082
by: Stefan Höhne | last post by:
Hi, as I recon, std::vector::clear()'s semantics changed from MS VC++ 6.0 to MS' DOT.NET - compiler. In the 6.0 version the capacity() of the vector did not change with the call to clear(), in DOT.NET the capacity() is reduced to 0.
7
12642
by: William Payne | last post by:
(This post is related to "recent files menu"-post below. If I should have kept this in that thread, I apologise.) Hello, I have a function that adds a std::string to a std::vector. New entries are added at the front (index 0) of the vector. If the vector contains a certain amount of elements, the element at the back is removed when a new one is added. If one tries to add a string already stored in the vector, that string is supposed to...
2
12064
by: Andy | last post by:
Hi, I did not find documentation on this. I try the following naive program, #include <vector> #include <iostream> using namespace std;
10
4851
by: Bob | last post by:
Here's what I have: void miniVector<T>::insertOrder(miniVector<T>& v,const T& item) { int i, j; T target; vSize += 1; T newVector; newVector=new T;
11
4366
by: eeykay | last post by:
Hello, I am facing a starnge problem while erasing the last member in a vector. I am using VC++ .NET 2002 complier. I have vector of CComPtr<..> (irrelevant here), and then I iterate over the vector. If it is the iterator, then I remove the element from the vector using vecObjects.erase(it). It works fine till the last element. While removing the last element it throws exception and fails. But the same vecObject.clear() works with out...
8
4915
by: Jason Heyes | last post by:
Does the STL have a function like this one? template <typename T> void remove(std::vector<T> &v, std::vector<T>::size_type index) { std::swap(v, v.back()); v.resize(index); } Unlike std::vector::erase, it calls T::operator= only three times no matter
3
6246
by: Jeff | last post by:
I have a question about potential memory leakage in a 2 dim array I have. If I say: vector< vector<int> > vec; vec.push_back( vector<int>() ); // initialize the row vec.push_back(1); vec.push_back(2);
3
2795
by: Sarath | last post by:
Dear All, at the time class destruction, application error occurs. Seems the heap was corrupted with the pop_back operation on empty vector. the code failed to execute in Visual C++ 6 and 2008. but worked fine in DevCPP. I admit that the pop function should check for empty vector. but still the different behavior concludes, it's a bug in Microsoft STL Implementation
0
1271
by: James Kanze | last post by:
On Jul 17, 10:27 am, Sarath <CSar...@gmail.comwrote: Or rather, that you've undefined behavior in your code. Garbage in, garbage out, as they say. (From a quality of implementation point of view, of course, the code should crash, at least in debug mode. Which is what all of my implementations -- Sun CC, g++ and VC++ -- do, once I fix the errors which prevent it from compiling.)
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9600
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10114
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9198
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7651
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5548
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5686
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3011
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.