Click to See Complete Forum and Search --> : strange but only in release mode


oreng
June 2nd, 2002, 10:42 AM
this is my code:
#include <stdlib.h>
#include <stdio.h>

typedef struct
{
double d1,d2;
int iSize;
} P;


int filter(P *pP)
{
int j;
pP->d1=107;
pP->d2=61;
pP->iSize=3;
double dCond;

dCond=(pP->d1<pP->d2);
printf("dCond=%f\n",dCond);
if (pP->d1 < pP->d2)
{
pP->iSize--;
printf("inside if\n",j);
}
else
pP->iSize--;
return 0;
}


main()
{
P p;
filter(&p);

return 0;
}

in debug mode it is fine and the output is:
dCond=0.000000

but in release mode (when the optimization option under the C/C++ tab is 'maximize speed'). the output is strange (the if block is executed):
dCond=0.000000
inside if

could someone have an explaination to this ?
I'm running microsoft visual C++ 6.0 enterprise edition.

Paul McKenzie
June 2nd, 2002, 10:49 PM
The code worked fine for me, both in debug and release.

Regards,

Paul McKenzie

Jupiter
June 2nd, 2002, 10:59 PM
Even the code worked fine at my end too both in debug and release mode!!