Access Violation with Insert Iterator 
Author Message
 Access Violation with Insert Iterator

I wonder if anyone has seen this problem before.
I'm using the Plauger implementation of STL for Windows, version 3.0.6, on
VC 6.0 SP3.
I encountered access violation when I tried to use the insert iterator for
copying string containers.
The error doesn't occur regularly. Access violation usually occurs on the
second iteration of the
outer loop.

I won't have any problem if I use the insert method on the
container. Following is the code that I used to cause the access violation.
Thanks for your information.

int main(int argc, char* argv[])
{
 typedef std::list<std::wstring> Container_t;
 typedef std::set<std::wstring> Set_t;
 srand( (unsigned)time( NULL ) );

 const int MaxIter = 1000;
 for( int j = 0; j < MaxIter; ++j )
 {
  const int MaxList = rand() % 255 + 1;
  std::wcout << L"Pass " << j << L" MaxList " << MaxList << std::endl;

  Container_t source;
  for( int i = 0; i < MaxList; ++i )
  {
   std::wostringstream str;
   str << L"A long string..." << rand()*rand();
   source.push_back(str.str());
  }

  Set_t destination;
  std::copy(source.begin(), source.end(), std::inserter(destination,
destination.begin()));
 }

 return 0;

Quote:
}



Tue, 30 Sep 2003 05:53:36 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. map::insert - Memory Access Violation Error

2. iterator invalidation by deque::insert

3. Problems with basic_string.insert(iterator, _E)

4. insert and iterators

5. Q: set<>.insert() w/ hint iterator use

6. "Access violation" accessing a DLL

7. URGENT: Access Violation when accessing the POOM IAppointment

8. Iterator and const Iterator?

9. access violation in

10. Access violation exception in Visual studio 7.0

11. access violation due to bad CString copy ctor when porting from VC6 to VC7 (VC++.NET)

12. VB Access Violation from C DLL

 

 
Powered by phpBB® Forum Software