Additional White Space breaks Debug when checking for "Status"!

So I ran into a problem where Status wasn’t appearing during debug. Yes, the debug config is set to debug and not release, and if it somehow has release optimizations, I have zero idea how that works because literally the tool doesn’t let you look any deeper than changing the processor type.

void PlayGame()
{
BCGame.Reset();
int32 MaxTries = BCGame.GetMaxTries();
std::cout << "Maximum tries: " << MaxTries << std::endl;
std::cout << std::endl;

// loop for the number of turns for asking guesses
// TODO change from FOR to WHILE loop once we are validating tries
for (int32 count = 1; count <= MaxTries; count++)
{
    FText Guess = GetGuess();

    EGuessStatus Status = BCGame.CheckGuessValidity(Guess);


    // submit valid guess to the game
    FBullCowCount BullCowCount = BCGame.SubmitGuess(Guess);

    // print number of bulls and cows
    std::cout << "Bulls = " << BullCowCount.Bulls;
    std::cout << ". Cows = " << BullCowCount.Cows << std::endl;
    std::cout << std::endl;
}

// TODO summarise game here

}

The additional white space between EGuessStatus and the // comment below it apparently broke the debug for me, preventing Status from appearing. After a good amount of frustration and wondering what the hell was wrong with it while posting to the discord chat (where no one’s awake at 4am pst), I finally narrowed it down to literally just removing that space. I couldn’t figure out WHY in the world copy/pasting the Github repo version of the code would work just fine, but mine wouldn’t. There was no functional reason why. And then I narrowed it down to that.

Isn’t half the point of C++ that you can have as much white space as you want and it wouldn’t matter??

TLDR: Don’t have doubled newline white spaces if Status isn’t appearing.

I’m not sure if I’m correctly understanding your question so correct me if I’m wrong.

You were trying to debug Status value right? And when you’ve added the breakpoint on the line with Status it didn’t stopped executing your code?

Are you sure you’ve put the breakpoint on correct line?

What IDE are you using? VS or Xcode? I’m no expert with Xcode but I remember that MonoDevelop wouldn’t catch breakpoints if they weren’t set on a line with executable code (for eg. on curly braces}. Visual Studio (at least my version) is automatically changing breakpoint location to the first available line that contains some actual code. If you’re using Xcode maybe that is where the problem lies?

I’m definetly sure though that adding any new lines there is not affecting how C++ works :wink:

The steps you may take as well is to check this issue it to add breakpoint inside CheckGuessValidity() to see if there are any errors.

You also might try to remove the breakpoint and add it again, maybe you’ve changed something accidentaly in its settings so it’s not invoked.

The worst case have you tried to turn off and on again both your IDE and your computer? It sometimes helps :slight_smile:

Let me know did you solved the issue.

I put the breakpoint right after the the line for EGuessStatus. Running debug wouldn’t show Status as a thing that would return data at all until I removed the addtional newline whitespace. The problem was solved by removing the white space. It makes ZERO SENSE why this is a problem. This was done in Visual Studio 2017 Community.

I remember when I was starting learning cpp and there was also a lot of stuff that in my opinion should have zero sense but when I’ve digged deeper then it usually has been a mistake made on my side.

I’m sure this behaviour should not be happening and I really encourage you to find out why it is really happening.

I’m not sure how I could help you more with it because it is impossible for me to even reproduce your bug.

Have you tried to clean your solution and then rebuild it?

https://msdn.microsoft.com/en-us/library/5tdasz7h.aspx

Privacy & Terms