Re: in standard C it is impossible to write a correct program. Why?
- From: Phil Carmody <thefatphil_demunged@xxxxxxxxxxx>
- Date: Fri, 04 Sep 2009 00:21:32 +0300
richard@xxxxxxxxxxxxxxx (Richard Tobin) writes:
In article <pan.2009.09.02.18.09.51.0@xxxxxxxxxxx>,
Nobody <nobody@xxxxxxxxxxx> wrote:
Does the lcc-win documentation provide sufficient information to determine
the last arithmetic operation performed when evaluating a particular
expression?
I would have thought it was far less ambiguous to provide a built-in
"function" (probably a macro):
check_overflow(expression)
which returns true if overflow occurs during the evaluation of the
expression. This doesn't require any odea of "last operation', makes
no assumption about overflow being indicated by a flag, and allows the
compiler to generate different (perhaps slower) code in cases where
overflow needs to be checked for.
For example:
You forgot these lines:
long long int a=~0u>>1, b=a;
short int c;
if(check_overflow(c = a+b))
fprintf(stderr, "sorry, overflow in addition\n");
But there was no overflow in addition, the overflow was in the
attempt to assign the greater-than-short value to the short variable.
Phil
--
If GML was an infant, SGML is the bright youngster far exceeds
expectations and made its parents too proud, but XML is the
drug-addicted gang member who had committed his first murder
before he had sex, which was rape. -- Erik Naggum (1965-2009)
.
- Follow-Ups:
- Re: in standard C it is impossible to write a correct program. Why?
- From: Richard Tobin
- Re: in standard C it is impossible to write a correct program. Why?
- From: Ben Bacarisse
- Re: in standard C it is impossible to write a correct program. Why?
- References:
- in standard C it is impossible to write a correct program. Why?
- From: io_x
- Re: in standard C it is impossible to write a correct program. Why?
- From: Nobody
- Re: in standard C it is impossible to write a correct program. Why?
- From: jacob navia
- Re: in standard C it is impossible to write a correct program. Why?
- From: Nobody
- Re: in standard C it is impossible to write a correct program. Why?
- From: Richard Tobin
- in standard C it is impossible to write a correct program. Why?
- Prev by Date: Re: in standard C it is impossible to write a correct program. Why?
- Next by Date: Re: Lcc win overflow handling
- Previous by thread: Re: in standard C it is impossible to write a correct program. Why?
- Next by thread: Re: in standard C it is impossible to write a correct program. Why?
- Index(es):
Relevant Pages
|