Bug in post-increment operator

Started by kia, August 09, 2006, 07:55:52 AM

Previous topic - Next topic

kia

Hi,

 For same condition, post-increment operator making wrong result.
For example:
 test = 1; foo( test++);
must pass to function foo the value equal 1, but it will be 2.

 This error will be if:
1. parameter type is short
2. must be switch on "Optimizes for size" or "Optimizes for speed"
3. calling conv is cdecl or stdcall

The example generated error:
CCFLAGS= -Tx86-coff -Ot -Gd -Ze -Zx

#include <stdio.h>

void testPar(short sp1, short sp2, int ip1, int ip2);

int main()
{
short sp1 = 1;
short sp2 = 1;
int   ip1 = 1;
int   ip2 = 1;

printf("\tTest PellesC\n");
testPar(++sp1, sp2++, ++ip1, ip2++);
getchar();

return 0;
}

void testPar(short sp1, short sp2, int ip1, int ip2)
{
printf("sp1=%u \tsp2=%u \n",sp1,sp2);
printf("ip1=%u \tip2=%u \n",ip1,ip2);
return;
}

skirby


Pelle

I will try to fix it. Looks pretty complicated, so it might take a while...
/Pelle

kia

Hi!
Version 4.50 it`s work now.

Very thanks for your work, Pelle!  =D>

Best Regards!