Code::Blocks Forums

User forums => Help => Topic started by: GJC on September 04, 2009, 11:09:59 am

Title: Debugging Question
Post by: GJC on September 04, 2009, 11:09:59 am
Why does the debugger stop/break at code within 'if' statements when conditions are not met.?
Hopefully i am doing something strange or incorrectly but would appreciate any help. For example
every time i run in debug mode the debugger breaks within statements that aren't met such
as

if (x==5)
{
 y++; //with a breakpoint here
}

the compiler/debugger stops everytime even tho x != 5
Title: Re: Debugging Question
Post by: Seronis on September 04, 2009, 08:17:49 pm
I'm sorry but using the following test program i was not able to reproduce your problem.

Code
#include <iostream>

using namespace std;

int testFunc() {
int x = 10;
if( x == 5 ) {
int y;
y = 9; //breakpoint set here
}
return x;
}

int main() {
    cout << "Hello world!" << endl;
    return testFunc();
}
Title: Re: Debugging Question
Post by: MortenMacFly on September 04, 2009, 08:54:56 pm
if (x==5)
{
 y++; //with a breakpoint here
}
If "x" is a float or double (so not an integer) this behaviour is correct.

Neverteheless - if you want help post the whole program so we are able to reproduce. Otherwise I can oly say: It works well for me.