Returning a true in a function that has a bool return type

Started by
13 comments, last by Servant of the Lord 9 years, 1 month ago

I'm actually not seeing that in Visual Studio too much, though there is probably one rule of thumb to follow: never change and save a source file while compiling. That's the one case I found where you often end up with the old version getting compiled and the new version being considered "already up to date" on subsequent builds.

f@dzhttp://festini.device-zero.de
Advertisement

What exactly is it running instead?

Code you wrote in the past.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

Learning exercise: What happens here when bagOfTetriminos is empty?

if ((*_bagOfTetrominos.front()).checkCollision())

... nothing good, that's for sure. huh.png

Learning exercise: What happens here when bagOfTetriminos is empty?


if ((*_bagOfTetrominos.front()).checkCollision())

... nothing good, that's for sure. huh.png

Thankfully that situation has arrived, but you are correct I have been failing in terms of error checking. Appreciate the reminder ;) Also have since converted to " -> " looking back at that makes me sad.

One thing I do is "sanity check" to confirm what part of the code is having the problem.

In this case, I would've done something like this:


std::cout << "checkCollision() result: " << (aSingleTetromino.checkCollision()? "true" : "false") << std::endl;

Note that, not only is it possible that the compiled code you are running isn't the written code that you are reading, but it's also possible that, when stepping through with a debugger, the debugger can show you the wrong values. It makes programming extra super duper fun! mellow.png

This happens a lot; especially under Windows with Visual Studio. Do a clean and rebuild.

With MinGW also! Microsoft's compiler doesn't have a monopoly on bugs. tongue.png

This topic is closed to new replies.

Advertisement