This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c/7479: wrong arithmetic output
- From: olivier dot baudron at m4x dot org
- To: gcc-gnats at gcc dot gnu dot org
- Date: 3 Aug 2002 15:59:56 -0000
- Subject: c/7479: wrong arithmetic output
- Reply-to: olivier dot baudron at m4x dot org
>Number: 7479
>Category: c
>Synopsis: wrong arithmetic output
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Aug 03 09:06:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: olivier.baudron@m4x.org
>Release: gcc-3.1.1
>Organization:
>Environment:
>Description:
The following testcase produces a wrong output:
#include <stdio.h>
int f() { return 1; }
int main(int argc, char **argv) {
int n=1, a, b;
a = (1 | (2 - f())) | (-n);
b = (1 | (2 - 1)) | (-n);
printf("a=%d b=%d\n", a, b);
return 0;
}
$ gcc -Wall -o test test.c
$ ./test
a=1 b=-1
It should be: a=1 b=1
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: