Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: error-debug assertion failed  (Read 2021 times)

0 Members and 1 Guest are viewing this topic.

Anand

  • Newbie
  • *
  • Posts: 11
    • View Profile
error-debug assertion failed
« on: March 19, 2016, 08:34:43 am »
i use visual studio 2015. i am creating a class textureholder to load and access the textures in sprite using std::map and on building the project gives debug assertion failed error. i have copied the image in the folder of the project.
i have attached the snapshot of the code , error, the folder of the project which i am doing.
please help me out

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10838
    • View Profile
    • development blog
    • Email
AW: error-debug assertion failed
« Reply #1 on: March 19, 2016, 09:01:31 am »
If you click retry the debugger would step in and pause the execution. Then you'd know exactly where the error happened and get a full stack trace.

The assertion also pretty much explains what's going on. You're trying to dereference a map iterator. Since there's only one dereference operator, I assume that's where error happens.

return *found->second;

Maybe that should be
return *(found->second)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Anand

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: error-debug assertion failed
« Reply #2 on: March 19, 2016, 02:08:51 pm »
sorry sir but the same error message appears after the modification which you have suggested.
help furthure

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: error-debug assertion failed
« Reply #3 on: March 19, 2016, 02:59:27 pm »
You load the airplaine texture, and then use the scene texture. Since it's not loaded, it can't be found in the map and the iterator that you get after the call to "find" is invalid, thus it can't be dereferenced.

When you hit an assertion, you can break and use the debugger to walk back the call stack, and watch variables and function arguments to find out what's wrong in your code.
Laurent Gomila - SFML developer

Anand

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: error-debug assertion failed
« Reply #4 on: March 19, 2016, 07:36:01 pm »
thank you sir. it now works