Jump to content
  • Advertisement
Sign in to follow this  
Solance

C++ skipping parts of code?

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

in my game sometime its just like the program skips parts of code when i break and step through it, it is in fact just jumping into the middle or so of a function any idea what causes this and how to fix it?

Share this post


Link to post
Share on other sites
Advertisement
Is the skipped code part of an if statement with a condition that is never true? Why not post the code in question so we can help you better?

Share this post


Link to post
Share on other sites
I have seen this occur when you haven't got your debug mode set correctly, that is if you still have any compiler optimisations switched on. The actual code that is generated by the compiler sometimes gets changed during optimisation process and thus doesn't match your displayed code anymore and can jump around and miss instructions entirely.

Make sure you have your debug mode set to no optimisation at all so all instructions are compiled into the resulting executable.

Share this post


Link to post
Share on other sites
1) check out the compiler warnings. It might say "unreachable code" or something similar.

2) the code could do nothing and be weeded out of the binaries.

3) is the code inside a #ifdef / #endif block?

4) If it's a release build, I don't think it would skip parts of the code, you would not be able to step into inline functions.

5) rebuild all. paying attention to compiler warnings. Always good to fix EVERY warnings you encouter too, so that stuff doesn;t get lost in the output spam.

Share this post


Link to post
Share on other sites
If you're stepping through a release build, it may jump over things in an unpredictable manner, as things get cut and reshuffled by the optimizer. If you want to step through code, make sure you're using a debug build.

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!