Jump to content

Image of the Day

Everything is fine. 

#screenshotsaturday #indiedev #gamedev https://t.co/98BAKUInyo
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net's newsletters to receive the latest updates and exclusive content.


Sign up now

vector iterator not dereferencable

4: Adsense

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   

652
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.

#2 JTippetts   Moderators   

12491
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   

652
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.