🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.micro.amiga
Article #4951

Re: LATTICE BUG (3.03) -unsigned? short optimization bug

#4951
From: Matt Dillon
Date: Thu, 16 Oct 1986 15:43
41 lines
1835 bytes
>>
>>	All integral arguments, baring floating expressions, for arithmatic 
>>operations are supposed to be extended to INT if they are <= INT.  On Lattice,
>>this is 32bits.
>>
>>						-Matt
>>	
>However this is pretty poor coding practice. If you expected the results
>to overflow a 16bit the programmer should have made allowances for this.
>It's those kind of problems that give compiler writers a severe headache
>when trying to do some intelligeant optimizing code generation.
>Dale Luck

	#@$#@$ it is NOT poor coding practice to assume your compiler will
follow the ansi (or K&R for that matter) standard.  Frankly, I was doing
some pretty mean thing with the code that blew (it was the core of some
3-D graphics functions) and it took me hours to trace down the problem.

	"If you expected the results to overflow a 16bit"... I expected the
results to be 32bit, so obviously I could not have expected the results to
overflow a 16bit.  It should be fixed.

					-Matt

(Lattice 3.03 documented unsigned short bug)

main()
{
   unsigned short a, b, c;

   a = 0xFFFF;
   b = 1;
   c = (a + b) / 2;
   printf ("result = %ld expect %ld\n", (long)c, 0x10000 / 2);
}

a.out
result = 0 expect 32768

	
Technical Details
Message-ID: <8610161543.AA27828@cory.Berkeley.EDU>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!rutgers!sri-spam!nike!ucbcad!ucbvax!CORY.BERKELEY.EDU!dillon

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!rutgers!sri-spam!nike!ucbcad!ucbvax!CORY.BERKELEY.EDU!dillon
From: dillon@CORY.BERKELEY.EDU (Matt Dillon)
Newsgroups: net.micro.amiga
Subject: Re: LATTICE BUG (3.03) -unsigned? short optimization bug
Message-ID: <8610161543.AA27828@cory.Berkeley.EDU>
Date: Thu, 16-Oct-86 11:43:35 EDT
Article-I.D.: cory.8610161543.AA27828
Posted: Thu Oct 16 11:43:35 1986
Date-Received: Thu, 16-Oct-86 22:50:48 EDT
Sender: daemon@ucbvax.BERKELEY.EDU
Organization: University of California at Berkeley
Lines: 41