NO

Author Topic: Debugger bug or optimisation bug  (Read 2700 times)

lostcentaur

  • Guest
Debugger bug or optimisation bug
« on: January 03, 2012, 12:41:35 AM »
The following code in debugger mode - by stepping with F10 will jump from the first if statement right to the last statement while pC not being NULL.
(This code is part of a project ported from VS2005)

int CmmnHandleSelected(tsConsoleCtrl *pC,tsList *pL,HWND hWnd)
{
 tsWndCtrl rWnd;
 HWND hWndList;

 if (pC == NULL)
   {
    pC = (tsConsoleCtrl *)GetWindowLongPtr(ghWndTBCombo,GWLP_USERDATA);
    if (pC != NULL)
     {
      rWnd = pC->rWnd;
     }
   }
 else
   {
    rWnd = pC->rWnd;
   }

 // Als beide lijsten leeg zijn, FALSE teruggeven
 if ((pL == NULL) AND (rWnd.prRows == NULL)) return(0);

CommonTater

  • Guest
Re: Debugger bug or optimisation bug
« Reply #1 on: January 03, 2012, 04:00:46 AM »
if PC is not NULL  the next step in your program would be the final if statement... since debug is just tracing your code's execution, it makes sense it would jump past it... 



lostcentaur

  • Guest
Re: Debugger bug or optimisation bug
« Reply #2 on: January 03, 2012, 10:12:38 AM »
No No, it does nothing with the first if then block !!  not even the else tag, what I would expect him to do.  It jumps to the next if, as if the first if-then-else block was completely ignored.
Now I did some further testing and it is clearly an optimisation bug for when I turned optimisation to 'none', the code runs fine - as should.  The else part is used and a values was given for the variable.

CommonTater

  • Guest
Re: Debugger bug or optimisation bug
« Reply #3 on: January 03, 2012, 11:53:42 AM »
No No, it does nothing with the first if then block !!  not even the else tag, what I would expect him to do.  It jumps to the next if, as if the first if-then-else block was completely ignored.
Now I did some further testing and it is clearly an optimisation bug for when I turned optimisation to 'none', the code runs fine - as should.  The else part is used and a values was given for the variable.

Another optimizer bug... ouch.  That's three now.

Sorry if I misunderstood.