NO

Author Topic: Bug in post-increment operator  (Read 2976 times)

kia

  • Guest
Bug in post-increment operator
« 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
Code: [Select]

#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

  • Guest
Bug in post-increment operator
« Reply #1 on: August 09, 2006, 09:54:28 AM »
I can confirm this behavior.

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Bug in post-increment operator
« Reply #2 on: August 11, 2006, 03:58:21 PM »
I will try to fix it. Looks pretty complicated, so it might take a while...
/Pelle

kia

  • Guest
Bug in post-increment operator
« Reply #3 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!