This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c/1978: gcc 2.95.2 in HP-UX 10.20 with -O2 generates wrong code



>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:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]