Jump to content
  • Advertisement
Sign in to follow this  
acidchaos

STL vector exception handling problems

This topic is 4916 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

Ok so heres is how my STL vector is setup: ////////// std::vector<CShader *> vShaders; vShaders.push_back (new CShader()); ////////// at the push_back line the program gets an unhandled exception: Unhandled exception at 0x00420846 in projekt.exe: 0xC0000005: Access violation reading location 0x00000004. and it stops in the file vector on line 516 inside the function: ////////// size_type size() const { // return length of sequence return (_Myfirst == 0 ? 0 : _Mylast - _Myfirst); } ////////// My CShader looks like this: ////////// class CShader { public: CShader(void); ~CShader(void); void load(char * fileName); char* getName(void); char* getVertexShader(void); char* getFragmentShader(void); protected: char name[128]; char* fragmentShader; char* vertexShader; }; ////////// Can someone please help me ive been trying to fix this for about 2 hours now and its not budging. Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement

  1. You can put code in the [ source ] tag (without the spaces), which will make your posted code easier to read.

  2. Your code is trying to read from address 0x00000004. I don't see why that would happen in an std::vector, perhaps the this pointer in the function is null (somehow).

Share this post


Link to post
Share on other sites
Have you overloaded operator new?
Does the constructor for CShader do aything wih vectors?
Is the code you posted exactly as it is written in your application?

If the answer to all of those is no, then I've got no idea why yur code isn't working.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!