This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
c/1978: gcc 2.95.2 in HP-UX 10.20 with -O2 generates wrong code
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c/1978: gcc 2.95.2 in HP-UX 10.20 with -O2 generates wrong code
- From: Sami dot J dot Salonen at nokia dot com
- Date: 14 Feb 2001 12:45:26 -0000
- Cc: Peter dot Toft at nokia dot com
- Reply-To: Sami dot J dot Salonen at nokia dot com
>Number: 1978
>Category: c
>Synopsis: gcc 2.95.2 in HP-UX 10.20 with -O2 generates wrong code
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Wed Feb 14 04:46:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: Sami Salonen, Peter Toft
>Release: gcc version 2.95.2 19991024
>Organization:
>Environment:
HP Visualize B2000 with HP-UX 10.20
(also some other machines with HP-UX are tested)
>Description:
When the source is compiled with
gcc -O2 foo.c
after running ./a.out I get
1 2 0
which is clearly not correct.
Any other optimization level than 2 is ok, and
I was not able to reproduce this bug in any other platform
than HP-UX 10.20 (tried mingw, cygnus and Sun)
The problem seems to be with defining the function
argument as constant - without it gives the correct results;
also further calls to the same function give correct results
e.g. if I call c_test twice I get
1 2 0
1 2 3
>How-To-Repeat:
#include <stdio.h>
struct st {int a,b,c;};
void c_test(
struct st input
);
void c_test(const struct st X) {
printf("%d %d %d\n", X.a, X.b, X.c);
}
int main(void) {
struct st X;
X.a = 1;
X.b = 2;
X.c = 3;
c_test((const struct st)X); /* the same result with and without cast */
return 0;
}
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: