Re: C return a++ - is it safe?
- From: RoS <Ros@xxxxxxxxx>
- Date: Sun, 04 Nov 2007 09:55:48 +0100
In data Thu, 01 Nov 2007 09:56:28 -0500, CBFalconer scrisse:
Chris Hills wrote:
Dave Hansen writes... snip ...
Chris Hills <ch...@xxxxxxxxxxxx> wrote:
Richard Harter <c...@xxxxxxxx> writes
Offhand, I would think that it is the sort of thing that a
compiler could be expected to get right but I might well be
wrong.
In other words you wouldn't bet your life on it....
In that case (betting my life), Ada has no advantage over C.
Absolutely,.... For years I have been arguing there is no such
thing as a "safe" language. It is all down to the quality of the
implementation
Yes, no language is 'safe'. However, some are much safer than
others. For example, the presence of subtypes (such as Pascals
ranges) simply allows range checking everywhere. Whenever a
construct creates a value for that item that is known to be out of
range, the compiler complains. When a runtime operation exceeds
that range, the runtime complains. Similarly the accurate control
of pointers allows most misuse of pointer variables to be detected
_at compile time_. This is a great advantage over C.
i think i'm in your kill file so don't read what i write;
the same for very pedands ones
-----------------------------------------------------------------
------------------------------------------------------------------
you and other seems not understand the esistance of variables that
*can not* overflow e.g. size_t; or
int, unsigned, float, double etc in financial calculis etc etc
if some of that variables has an overflow it has to rappresent an
error number (eg: INT_MAX for +overflow and INT_MIN for -overflow)
so detect errors in run time is more easy
for an unsigned thype the aritimetic is very easy
0..UMAX
a+b = (a==UMAX || b==UMAX || oveflow(a+b)? UMAX : sum(a, b);
a-b = (a==UMAX || b==UMAX || a<b || oveflow(a-b)? UMAX : sum(a, b);
some like above for -*/
0..UMAX-1 is ok
UMAX is an error
Unfortunately Pascal seems to have largely disappeared as a major
language. We are left with its descendent, Ada, which is a larger,
safer, and tested language. And also available in gcc.
--.
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
- Follow-Ups:
- Re: C return a++ - is it safe?
- From: Keith Thompson
- Re: C return a++ - is it safe?
- From: santosh
- Re: C return a++ - is it safe?
- References:
- Re: C return a++ - is it safe?
- From: Chris Hills
- Re: C return a++ - is it safe?
- From: CBFalconer
- Re: C return a++ - is it safe?
- Prev by Date: Re: mnemonic
- Next by Date: Re: mnemonic
- Previous by thread: Re: C return a++ - is it safe?
- Next by thread: Re: C return a++ - is it safe?
- Index(es):
Relevant Pages
|
|