Mail Archives: cygwin/2000/08/17/18:07:53
This code has produced 3 different results on 4 systems.
The second result was on the Cygwin B20 system
#include <stdio.h>
int i;
void do_increment(int array[]){
for(i;i<10;){
array[i++]=i;
}
}
void print_array(int a, int b, int c){
printf("%i\t%i\t%i\n",a,b,c);
}
main(void){
int array[10];
i=0;
do_increment(array);
i=0;
/* This use of var++ in a function call is
unpredictable */
print_array(array[i++],array[i++],array[i++]);
}
B20 (gcc 2.91.57) on NT 4 output:
2 1 0
The only workarround is to know how your system behaves or define temp
variables. a similar function call was used by a client, and our tests
showed it failing, since our tester was using VStudio. The client was using
the Tasking complier.
However, this works on some platforms and could become an error in porting
software. As to patching... I haven't tried the latest gcc, and I'm not
versed in compiler theory.
I was not able to find information about this on GNATS or in the cygnus
mailing list archives.
gcc 2.8.0 on solaris (expected answer)
0 1 2
Microsoft Visual Studio 6
0 0 0
Our fourth platform was a Tasking compiler for a Seimens micro
It behaved as we expected (no stdio though).
--
Brian Ball
Software Engineer - SEP
mailto:bjball AT sep DOT com
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com
- Raw text -