Author Topic: Debugging Question  (Read 3595 times)

GJC

  • Guest
Debugging Question
« 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

Offline Seronis

  • Almost regular
  • **
  • Posts: 197
Re: Debugging Question
« Reply #1 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();
}

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: Debugging Question
« Reply #2 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ