473,383 Members | 1,877 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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 3168
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
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...
7
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...
2
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
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
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...
8
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...
3
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);...
3
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...
0
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.