Sun C compiler bug
Chris Torek
chris at umcp-cs.UUCP
Sat Jul 27 04:12:52 AEST 1985
Speaking of Sun C compiler bugs, how about
struct bug {
struct { int field:4; } array[128];
};
f()
{
register struct bug *p;
register int i;
p->array[i].field;
}
which generates
movl d7,d0
asll #1,d0
moveq #0,d0 ; sorry, guys, ya blew it
movb a5@(0,d0:l),d0
lsrl #4,d0
andb #0xf,d0
The code is just fine except for the minor fact that it is using
the same temp for both the subscript operation and the dereference.
Makes all references to "register pointer to array of bitfield"
access the 0th element, always. (The problem doesn't occur with
arrays of anything else, nor with pointers to bitfields.)
Without the compiler sources, of course, I can't provide a fix
(hint hint :-) ). Note however that the problem goes away if one
simply does not clear the destination of a move for a FLD reference,
since the result will be masked anyway....
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251)
UUCP: seismo!umcp-cs!chris
CSNet: chris at umcp-cs ARPA: chris at maryland
More information about the Comp.unix.wizards
mailing list