🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #2216

weird remainder bug on Vax with gcc 1.31

#2216
From: James.Aspnes
Date: Sat, 28 Jan 1989 01:40
23 lines
975 bytes
Don't know if this has been fixed in 1.32, but here's a sample
program:

% cat > bug.c
main()
{
    int a[10];

    a[4] = 7;
    a[a[4]] = 7;
    a[a[4]] = a[a[4]] % 3;
    printf("%d\n", a[a[4]]);
}
% gcc -o bug bug.c
% bug
0
%

Note that 0 != 7 % 3 == 1.  The actual values 4, 7, 3, etc.appear to
be irrelevant; the key to the problem seems to be the nested array
references.  The problem goes away when the assignment is replaced by
a[a[4] %= 3, or the optimizer is turned on (which I would guess to be
equivalent.)
Technical Details
Message-ID: <8901280139.AA02285@wheaties.ai.mit.edu>
Path: arc1-ca.pugleaf.net!utzoo!telly!ddsw1!lll-winken!killer!mit-eddie!bloom-beacon!tut.cis.ohio-state.edu!CS.CMU.EDU!James.Aspnes

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!ddsw1!lll-winken!killer!mit-eddie!bloom-beacon!tut.cis.ohio-state.edu!CS.CMU.EDU!James.Aspnes
From: James.Aspnes@CS.CMU.EDU
Newsgroups: gnu.gcc.bug
Subject: weird remainder bug on Vax with gcc 1.31
Message-ID: <8901280139.AA02285@wheaties.ai.mit.edu>
Date: 28 Jan 89 01:40:47 GMT
Sender: daemon@tut.cis.ohio-state.edu
Reply-To: asp@cs.cmu.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 23