🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.c
Article #9575

Re: Bug converting unsigned to double in BSD 4.[23]

#9575
From: Donn Seeley
Date: Sun, 09 Nov 1986 04:08
54 lines
2330 bytes
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
Technical Details
Message-ID: <3994@utah-cs.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!ut-sally!utah-cs!donn
References: <213@cartan.Berkeley.EDU>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!ut-sally!utah-cs!donn
From: donn@utah-cs.UUCP (Donn Seeley)
Newsgroups: net.lang.c,net.bugs.4bsd
Subject: Re: Bug converting unsigned to double in BSD 4.[23]
Message-ID: <3994@utah-cs.UUCP>
Date: Sat, 8-Nov-86 23:08:38 EST
Article-I.D.: utah-cs.3994
Posted: Sat Nov  8 23:08:38 1986
Date-Received: Sun, 9-Nov-86 05:58:41 EST
References: <213@cartan.Berkeley.EDU>
Organization: University of Utah CS Dept
Lines: 54
Summary: Oops -- an oversight, but easy to fix