int count(int d);
int dGlobalTest=0;
int dFunctionTest=0;
int count(d){
// d is not used
dGlobalTest=33;
dFunctionTest++;
return 1;
}
int main(int argc,char *argv[]){
for(int n=0;n<1000;n++){
dGlobalTest+=count(dGlobalTest);
}
printf("\r\n\r\n dGlobalTest = %d ,"
" dFunctionTest = %d \r\n\r\n",
dGlobalTest,dFunctionTest);
return 0;
}
I reckon it has to be a C language issue. Not a problem as such, it's called
undefined behaviour because you are referencing the same variable without an
intervening sequence point.
here
dGlobalTest+=count(dGlobalTest);
for example the following breaks this rule.
a[i] = i++;
John
Here are some notes that might help.
==================
From a FAQ on C
A sequence point is a point in time (at the end of the
evaluation of a full expression, or at the ||, &&, ?:, or comma
operators, or just before a function call) at which the dust
has settled and all side effects are guaranteed to be complete.
The ANSI/ISO C Standard states that
Between the previous and next sequence point an
object shall have its stored value modified at
most once by the evaluation of an expression.
Furthermore, the prior value shall be accessed
only to determine the value to be stored.
==================
John