Pelles C forum

Pelles C => Bug reports => Topic started by: kia on August 09, 2006, 07:55:52 AM

Title: Bug in post-increment operator
Post by: kia on August 09, 2006, 07:55:52 AM
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;
}
Title: Bug in post-increment operator
Post by: skirby on August 09, 2006, 09:54:28 AM
I can confirm this behavior.
Title: Bug in post-increment operator
Post by: Pelle on August 11, 2006, 03:58:21 PM
I will try to fix it. Looks pretty complicated, so it might take a while...
Title: Bug in post-increment operator
Post by: kia on September 06, 2006, 09:26:12 AM
Hi!
Version 4.50 it`s work now.

Very thanks for your work, Pelle!  =D>

Best Regards!