optimization/7702: gcc-3.2 optimization problem on a DEC alpha under OSF1

bfkelly@nsa.gov bfkelly@nsa.gov
Fri Aug 23 06:56:00 GMT 2002


>Number:         7702
>Category:       optimization
>Synopsis:       gcc-3.2 optimization problem on a DEC alpha under OSF1
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Aug 23 06:56:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     bfkelly@nsa.gov
>Release:        gcc-3.2
>Organization:
>Environment:
% uname -a
OSF1 peano V5.1 1885 alpha
% gcc -v
Reading specs from
/home/bluenet/bfkelly/public/gcc-3.2/OSF1/lib/\
  gcc-lib/alphaev67-dec-osf51./3.2/specs
Configured with: ../gcc-3.2/cponfigure --enable-languages=c \
  --prefix=/home/bluenet/bfkelly/public/gcc-3.2/OSF1
Thread model: single
gcc version 3.2
%
>Description:
/*
Demonstrates a gcc optimizatoin bug on a HP/Compaq/DEC alpha
under OSF1.

% uname -a
OSF1 peano V5.1 1885 alpha
% gcc -v
Reading specs from
/home/bluenet/bfkelly/public/gcc-3.2/OSF1/lib/\
  gcc-lib/alphaev67-dec-osf51./3.2/specs
Configured with: ../gcc-3.2/cponfigure --enable-languages=c \
  --prefix=/home/bluenet/bfkelly/public/gcc-3.2/OSF1
Thread model: single
gcc version 3.2
%
% gcc -O2 -o foo foo.c
% foo
i= 0 r[0] = 1
r[0] = 0
%
% gcc -O0 -o foo foo.c
% foo
i= 0 r[0]= 1
r[0]= 1
%
*/

#include <stdio.h>
#include <stdlib.h>

int car(x,y)
int   x;
int   y;
{
    return x+y;
}

void bar(a, n)
int   a;
int   n;
{
    int  i;
    int  g;
    int *r;

    g = 10;
    r = (int *) malloc(5 * sizeof(int));
    for (i = 0; i < n; i++)
    {
        if (i < 0) {
            r[i] = 1;
        } else {
            if (i == 0) {
              r[i] = 1;
printf("i= %d r[%d]= %d\n", i, i, r[i]);
            } else {
                g = car(g, a);
                r[i] = 2;
            }
        }   
    }
printf("r[0] = %d\n", r[0]);
}

int main()
{
    bar(5,1);
}

>How-To-Repeat:
% gcc -O2 -o foo foo.c
% foo
i= 0 r[0] = 1
r[0] = 0
%
% gcc -O0 -o foo foo.c
% foo
i= 0 r[0]= 1
r[0]= 1
%
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list