Jump to content

  • Log In with Google      Sign In   
  • Create Account

vector iterator not dereferencable


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 lride   Members   -  Reputation: 633

Like
0Likes
Like

Posted 22 November 2012 - 11:32 PM

I have this piece of code. This is called once every frame
[source lang="cpp"] //While there is a message to deliverwhile(messageQueue.top().dispatchTime<=currentTime && !messageQueue.empty()) { //deliver the message messageQueue.top().receiver->handleMessage(messageQueue.top()); //delete the message messageQueue.pop(); }[/source]

This works fine in release, but when I run in debug mode, I soon get an assertion failure: "Debug Assertion Failed! vector iterator not dereferencable"

Edited by lride, 22 November 2012 - 11:34 PM.

An invisible text.

Sponsor:

#2 JTippetts   Moderators   -  Reputation: 8649

Like
2Likes
Like

Posted 22 November 2012 - 11:36 PM

You should put the !messageQueue.empty() test before you attempt to dereference top(), in case the queue actually is empty which would mean that messageQueue.top().dispatchTime is trying to dereference end() iterator.

#3 lride   Members   -  Reputation: 633

Like
0Likes
Like

Posted 22 November 2012 - 11:40 PM

Thank you. That fixed it.
An invisible text.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS