Package: gcc
Version: 4:4.0.3-4

gcc -v
gcc version 4.0.4 20060507 (prerelease) (Debian 4.0.3-3)

Hi!

I use testing version of debian with gcc4, and it compiles the following c code wrong way:

#include <stdio.h>

int a=13;
int t[1]={13};
int b=13;
int *p;

int main()
{
  p=&b;
  printf("a:%d t[0]:%d *p:%d\n",a,t[0],*p);
  a+=(a=2)+(a=3);
  t[0]+=(t[0]=2)+(t[0]=3);
  (*p)+=((*p)=2)+((*p)=3);
  printf("a:%d t[0]:%d *p:%d\n",a,t[0],*p);

  a=2;
  t[0]=2;
  *p=2;
  a+=(a=6);
  t[0]+=t[0]=6;
  (*p)+=(*p=6);
  printf("a:%d t[0]:%d *p:%d\n",a,t[0],*p);
}


[EMAIL PROTECTED]:~/src/nyesoteric/urisc/bugvadasz$ gcc a.c && ./a.out
a:13 t[0]:13 *p:13
a:8 t[0]:18 *p:18
a:12 t[0]:8 *p:8

While gcc 3.4 seems ok:
[EMAIL PROTECTED]:~/src/nyesoteric/urisc/bugvadasz$ gcc-3.4 a.c && ./a.out
a:13 t[0]:13 *p:13
a:8 t[0]:8 *p:8
a:12 t[0]:12 *p:12

(Both compiled without -O flag)

__________________________________
Light thinks it travels faster than anything but it is wrong. No matter how fast light travels it finds the darkness has always got there first, and is waiting for it. - Terry Pratchett

Reply via email to