% cat bug.c
main ()
{
printf ("%u\n", ~ ((unsigned) 0));
printf ("%lf\n", (double) (~ ((unsigned) 0)));
printf ("%lf\n", 4294967295.0); /* surely double is large enough for this? */
}
% bug
4294967295
-1.000000
4294967295.000000
The results were the same on BSD 4.2 and BSD 4.3. Of course, the question
is, did I miss something? (I don't believe so.)
--------
Kenneth R. Ballou ...!ucbvax!cartan!brahms!ballou
Dept. of Mathematics
University of California
Berkeley, California 94720
The fix is very simple. Change the following two lines in makety() in
the compiler source file lib/mip/trees.c:
------------------------------------------------------------------------
RCS file: RCS/trees.c,v
retrieving revision 1.17
diff -c -r1.17 trees.c
*** /tmp/,RCSt1007207 Sat Nov 8 21:02:34 1986
--- trees.c Sat Nov 8 20:52:03 1986
***************
*** 1210,1216 ****
if (t == DOUBLE) {
p->in.op = DCON;
if (ISUNSIGNED(p->in.type))
! p->dpn.dval = /* (unsigned CONSZ) */ p->tn.lval;
else
p->dpn.dval = p->tn.lval;
p->in.type = p->fn.csiz = t;
--- 1210,1216 ----
if (t == DOUBLE) {
p->in.op = DCON;
if (ISUNSIGNED(p->in.type))
! p->dpn.dval = (unsigned CONSZ) p->tn.lval;
else
p->dpn.dval = p->tn.lval;
p->in.type = p->fn.csiz = t;
***************
*** 1219,1225 ****
if (t == FLOAT) {
p->in.op = FCON;
if( ISUNSIGNED(p->in.type) ){
! p->fpn.fval = /* (unsigned CONSZ) */ p->tn.lval;
}
else {
p->fpn.fval = p->tn.lval;
--- 1219,1225 ----
if (t == FLOAT) {
p->in.op = FCON;
if( ISUNSIGNED(p->in.type) ){
! p->fpn.fval = (unsigned CONSZ) p->tn.lval;
}
else {
p->fpn.fval = p->tn.lval;
------------------------------------------------------------------------
Don't ask me why these casts were commented out (argh!),
Donn Seeley University of Utah CS Dept do...@utah-cs.arpa
40 46' 6"N 111 50' 34"W (801) 581-5668 decvax!utah-cs!donn