Tuesday, December 29, 2015

Digest for comp.programming.threads@googlegroups.com - 6 updates in 3 topics

Ramine <ramine@1.1>: Dec 28 12:54PM -0800

Hello,
 
 
Here is the exception that you can catch in FreePascal if
you compile with the -Co option:
 
 
try
 
except
on EIntOverflow do HandleIntOverflow;
end;
 
 
And that's better than C++ and C, because on a more complex realtime
safety critical systems if you forget to test the overflow or underflow
you can risk more , but in FreePascal you can also catch the
EIntOverflow exception and this exception works for both
signed and unsigned 32 bit or 64 bit variables for multiplication
division and add etc. and that's better than C++ and C.
 
 
 
Thank you,
Amine Moulay Ramdane.
bleachbot <bleachbot@httrack.com>: Dec 28 06:23PM +0100

bleachbot <bleachbot@httrack.com>: Dec 28 06:42PM +0100

bleachbot <bleachbot@httrack.com>: Dec 28 06:54PM +0100

Ramine <ramine@1.1>: Dec 28 12:23PM -0800

Hello,
 
 
How can you test for signed int overflow..
 
Here is how you can do it in C and C++:
 
===
#include <limits.h>
int a = <something>;
int x = <something>;
if ((x > 0) && (a > INT_MAX - x)) /* `a + x` would overflow */;
if ((x < 0) && (a < INT_MIN - x)) /* `a + x` would underflow */;
/* ... same thing for subtraction, multiplication, and division */
===
 
 
But notice with me that this method in C and C++ is not
acceptable for realtime safety critical systems, because
on a more complex software for realtime safety critical systems,
you can forget to test for overflow of the integer and this can have a
bad consequence and even a catastrophe, so C++ and C are bad.
 
But with the Delphi mode of the FreePascal compiler you can do this:
 
Compile with -Cr(for range checking) and compile with -Co(for Integer
overflow checking), so even if on a more complex software for realtime
safety critical system you have forgot to test for for overflow of a
signed int or an unsigned integer , you can effectively catch the
exception of the overflow signed int or unsigned int with a Try Except
End; in the Delphi mode of FreePascal if you compile block with -Cr and
-Co, and that's better in FreePascal for realtime safety critical
systems, note also that i have just tested FreePascal with -Co and it
works for both overflow of a signed int or an unsigned int.
 
 
 
Thank you,
Amine Moulay Ramdane.
Ramine <ramine@1.1>: Dec 28 12:42PM -0800

Hello,
 
 
I have just tested -Co compiler option of the FreePascal
compiler, it will throw an exception that you can catch
from the software for both overflow and underflow.
 
 
Thank you,
Amine Moulay Ramdane.
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.programming.threads+unsubscribe@googlegroups.com.

No comments: