C compiler bug? Answer: No.
Mark G. Johnson
mark at mips.COM
Mon Jul 16 02:37:31 AEST 1990
The problem is this: the source code assumes it will be run on a
little-endian machine. Presumably the Sequent incorporates an
Intel CPU, which is little-endian. The SGI (as well as the Sun,
MIPS, and Apollo machines mentioned earlier) are all big-endian.
Further evidence comes from the DECstation 3100, a little-endian
machine which uses the same CPU (R2000) and same C compiler as the SGI.
However, the DS3100 gets the answer that John Forrest wants, CRC=9cda,
while the SGI does not.
You can monkey around in the debugger to see this, or you can insert
the following printf statement in between two existing assignments:
------------------------------------------------------------------------------
------------------------------------------------------------------------------
temp = (iUn.Bit.i7 ^ iUn.Bit.i6 ^ iUn.Bit.i5 ^
iUn.Bit.i4 ^ iUn.Bit.i3 ^ iUn.Bit.i2 ^
iUn.Bit.i1);
printf("DEBUG: iUn.i = %3d LSBs 4 3 2 1 = %d %d %d %d temp = %d\n",
(iUn.i), (iUn.Bit.i4), (iUn.Bit.i3), (iUn.Bit.i2), (iUn.Bit.i1), temp );
EntryUn.EntryBit.b16 = (iUn.Bit.i8 ^ temp);
------------------------------------------------------------------------------
------------------------------------------------------------------------------
On the SGI you find that "the LSBs" are all zeroes, while on the DS3100
they contain ones as appropriate.
In short, this "bug" seems to be a problem with the source code, not the
C compiler.
--
-- Mark Johnson
MIPS Computer Systems, 930 E. Arques M/S 2-02, Sunnyvale, CA 94086
(408) 524-8308 mark at mips.com {or ...!decwrl!mips!mark}
More information about the Comp.sys.sgi
mailing list