Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 Nov 1995 23:53:01 +1100
From:      Bruce Evans <bde@zeta.org.au>
To:        hsu@freefall.freebsd.org, kaleb@x.org
Cc:        hackers@freefall.freebsd.org
Subject:   Re: gcc-2.7.1 compiled kernel
Message-ID:  <199511281253.XAA29508@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>Is the -O2 -fno-strength-reduce bug fixed?

No, according to this.

Bruce

Article 4048 of gnu.gcc.bug:
Path: gidora.kralizec.net.au!warrane.connect.com.au!news.syd.connect.com.au!news.mel.connect.com.au!harbinger.cc.monash.edu.au!simtel!lll-winken.llnl.gov!uwm.edu!math.ohio-state.edu!cis.ohio-state.edu!crunch.ikp.physik.th-darmstadt.de!anlauf
From: anlauf@crunch.ikp.physik.th-darmstadt.de (Harald Anlauf)
Newsgroups: gnu.gcc.bug
Subject: Bug on i386/Linux with unsigned and -fstrength-reduce
Date: 22 Nov 1995 17:42:17 -0500
Organization: GNUs Not Usenet
Lines: 60
Sender: daemon@cis.ohio-state.edu
Approved: bug-gcc@prep.ai.mit.edu
Distribution: gnu
Message-ID: <9511222241.AA19094@crunch>

Hi,

I found an interesting bug in gcc versions 2.5.8, 2.7.0, and 2.7.1,
compiled as i486-*-linuxoldld and running under Linux.

Compiling the program given below with options:

-O2,
-O[123] -fstrength-reduce
-O[123] -fstrength-reduce -fno-unroll-loops

produces the (wrong) output:
A[0] = -3
A[1] = 0
A[2] = 0

whereas it gives the correct result with
-O[123] -fno-strength-reduce
-O[123] -fstrength-reduce -funroll-loops

produces the (correct) result:
A[0] = -3
A[1] = -2
A[2] = -1

The funny thing is that changing the unsigned integer B to a signed integer
fixes the problem.  The problem persists with "unsigned long", but goes
away for "unsigned short", "unsigned char", or "unsigned long long".

Anybody knows what's going on?

Ciao,
Harald

[I am not the original author of this little demo program.  Somebody posted it
to gnu.gcc.bug some time ago, but unfortunately I didn't keep the reference.
So please don't flame me.]

------------------------------> cut here <------------------------------
#include <stdio.h>

int A[3];
unsigned int B = 3;

void printit(void)
{
int i;
for(i = 0; i < B; i++)
fprintf(stdout, "A[%d] = %d\n", i, A[i]);
}

int main()
{
int i;
for(i = 0; i < B; i++)
A[i] = i - 3;
printit();
return 0;
}
------------------------------> cut here <------------------------------





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199511281253.XAA29508>