octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: warnings originating in gl2ps -- update


From: CdeMills
Subject: Re: warnings originating in gl2ps -- update
Date: Thu, 10 Feb 2011 03:56:55 -0800 (PST)


CdeMills wrote:
> 
> 
> It's not evident. I worked on removing such problems in a program of mine,
> there is no standard way. There should be a "safe cast" between signed and
> unsigned, verifying that there is no overwrap possible, like f.i. a great
> unsigned becoming a negative signed. I don't have 'off the shelves',
> simple solution. The other way is to use assert, but what to do in case of
> failures ? 
> 
> 

Sorry to reply with a follow-up to myself. A reference about the problem of
signed-unsigned comparison is at 

https://www.securecoding.cert.org/confluence/display/seccode/INT31-C.+Ensure+that+integer+conversions+do+not+result+in+lost+or+misinterpreted+data

The conclusion: either
1) catch through a test for possible overflow
2) cast both to a int which possess a wider representation that the widest
of both arguments. This way, no data overflow/underflow can occur, at the
cost of increased computation size.

Regards

Pascal

-- 
View this message in context: 
http://octave.1599824.n4.nabble.com/warnings-originating-in-gl2ps-update-tp3298345p3298978.html
Sent from the Octave - Maintainers mailing list archive at Nabble.com.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]