[gnu.gcc.bug] weird remainder bug on Vax with gcc 1.31

James.Aspnes@CS.CMU.EDU (01/28/89)

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.)