Jump to content
  • Advertisement
Sign in to follow this  
hupsilardee

Another strange error

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

Why do weird errors always happen to me? Here's the latest one. Simple screenie should explain whats going wrong, and my comments below:


errorjj.png

I'm working on heightmap-terrain. I create a new terrain in the main() function, circled at the top. I pass in 32 as the size.
In the terrain constructor, a breakpoint is hit, and inspection of the "size" argument reveals it has a value of ... whatever, it seems to change every time.

How the flying f*** can this be going wrong?

Share this post


Link to post
Share on other sites
Advertisement
Are you debugging an optimized build or a proper debug build? The former is not as easy and obvious to debug as the latter.

Share this post


Link to post
Share on other sites
In my experience with GDB parameters to c++ functions are not always displayed properly. If you are in debug build as BrotherBob suggests checking, I'd do a printf to confirm that it is not 32. Next thing, I'll check the address of "this" and the parameter "size" to see if for some weird reason "this" is pointing to the stack, and size is being wrongly modified, and the last thing is declaring the constructor (in the header) as

Terrain(GraphicsDevice* graphics, uint size=32);


and calling it (line 76 of your code) as:

Terrain* terrain = new Terrain(graphics);


Which should be a solution to the problem

Share this post


Link to post
Share on other sites
Visual c++ 2010, debug build.

I added
std::cout << "Size: " << size << std::endl;

at the top of the Terrain constructor, and it is indeed 32. So why does the debugger show a nonsense number?
The "this" variable also appears to be valid, checking with the locals window

Lastly, the constructor prototype/definition are perfectly matching
So the correct value is there, but I can't see that. Which is making debugging the Render method a nightmare...

Share this post


Link to post
Share on other sites
right click on solution > clean solution
right click on solution > rebuild solution
try again

VS debugger gave me strange values a few time, doing this always fix it.

Share this post


Link to post
Share on other sites
Sometimes it is just that the compiler modifies the stack/frame pointer slightly later than expected by the debugger, and you need to execute a couple instructions into the routine to have the correct value read

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!