[net.bugs.4bsd] Bug converting unsigned to double in BSD 4.23

donn@utah-cs.UUCP (Donn Seeley) (11/09/86)

A fair bit of code was added to make conversions from unsigned to
floating types work right in the 4.3 BSD VAX C compiler, but
unfortunately conversions of unsigned constants were never tested.
That's the way the cookie bounces.

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    donn@utah-cs.arpa
40 46' 6"N 111 50' 34"W    (801) 581-5668    decvax!utah-cs!donn