[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#376901: marked as done (gcc4 (*p)+=(*p=6) bug)



Your message dated Wed, 05 Jul 2006 19:40:23 +0200
with message-id <874pxw6jco.fsf@debian.org>
and subject line Bug#376901: gcc4 (*p)+=(*p=6) bug
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

--- Begin Message ---
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);
}


nyos@nyos:~/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:
nyos@nyos:~/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


--- End Message ---
--- Begin Message ---
NyOS <nyos@nyos.homelinux.net> writes:

>    a+=(a=2)+(a=3);

This modifies "a" more than once without an intervening sequence
point. Therefore, the behavior is undefined. gcc even warns about
this. See the documentation on -Wsequence-point.

-- 
	Falk

--- End Message ---

Reply to: