[M3commit] CVS Update: cm3

Jay K jay.krell at cornell.edu
Sun Jan 24 12:00:35 CET 2010


The previous form is not portable to systems that trap on overflow...if such a thing really makes sense.

It is good practise to avoid that in C too, since signed overflow is undefined,

and gcc actually sometimes mangles code that depends on signed overflow.

 

 

Really, look at how I got here. By using Target.Int in m3back and not ignoring errors.

And look at what I had to do to get it to compile with a warning.

I had to check for a specific value and hardcode the result.

This is actually needed in multiple places.

When I wrote test code that resembles the Lex code, it triggered a failure

to convert Target.Int to INTEGER in a different place in m3back.

 

 

 - Jay
 
> From: hosking at cs.purdue.edu
> Date: Sun, 24 Jan 2010 04:26:26 -0500
> To: jkrell at elego.de
> CC: m3commit at elegosoft.com
> Subject: Re: [M3commit] CVS Update: cm3
> 
> Seems overdone...
> 
> On 23 Jan 2010, at 20:34, Jay Krell wrote:
> 
> > CVSROOT: /usr/cvs
> > Changes by: jkrell at birch. 10/01/23 20:34:50
> > 
> > Modified files:
> > cm3/m3-libs/libm3/src/fmtlex/: Lex.m3 
> > 
> > Log message:
> > avoid integer overflow on two's complement systems:
> > replace -FIRST(INTEGER) with Word.Plus(-(FIRST(INTEGER) + 1), 1)
> > (The value is then passed to Word.GT.)
> 
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3commit/attachments/20100124/4bcc8412/attachment-0002.html>


More information about the M3commit mailing list