Jump to content
  • Advertisement
Sign in to follow this  
Bobs

[.net] STL Vector push_back crash during runtime

This topic is 3879 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm using an unmanaged C++ library with in a Windows Forms Application in Visual C++ .NET 2003 with Managed Extensions. I'm getting a crash during runtime from my library code when I try to use the push_back method on an STL Vector object. I get the following error message: "An unhandled exception of type 'System.NullReferenceException' occurred in Library.exe Additional information: Object reference not set to an instance of an object." It crashes on line 516 in the STL Vector class file: size_type size() const { // return length of sequence return (_Myfirst == 0 ? 0 : _Mylast - _Myfirst); } Is there anyway around this crash? Any input may help.

Share this post


Link to post
Share on other sites
Advertisement
The problem is probably in your code; most likely you're calling push_back() on a null pointer.

Share this post


Link to post
Share on other sites
Problem is now fixed. I was trying to push_back to an STL vector of vectors at an index that wasn't yet created. After I created all my indexes I was able to successfully call push_back at a specific index (of vector type) in the STL vector. Your input encouraged me to look over my code. Thanks a lot.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!