VS2019 step-by-step debugging skips loop iterations

Created a simple code with a loop on Visual Studio 2019:

#include <iostream>

using namespace std;

int main()
{
    int x = 10;
    while (x > 5)
    {
        cout << "something";
        x -= 1;
    }

    return 0;
}

To demonstrate the counter changes during the iterations of the loop, I started step-by-step debugging by pressing F10 and then moving through the lines of code with the same key. The current line pointer reached the first line of the loop body, and then just jumped to return 0, by setting the values of the variables as if the loop has already been executed. For previous versions of VS, this was not noticed.

Question: how to perform each iteration of the loop in steps with no gaps like the one described?

P.S. F9 does not help, it goes into the instruction itself, as, in fact, it should be.

Author: V-Mor, 2019-11-25

1 answers

You may have compiled a Release version. Build it in Debug.

 3
Author: EOF, 2019-11-25 17:42:47