Re: in standard C it is impossible to write a correct program. Why?



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:

if(check_overflow(c = a+b))
fprintf(stderr, "sorry, overflow in addition\n");

-- Richard
--
Please remember to mention me / in tapes you leave behind.
.



Relevant Pages

  • Re: in standard C it is impossible to write a correct program. Why?
    ... the last arithmetic operation performed when evaluating a particular ... no assumption about overflow being indicated by a flag, ... which required specifying a bool lvalue into which to ... the result of evaluating the expression and whether it overflowed. ...
    (comp.lang.c)
  • Re: in standard C it is impossible to write a correct program. Why?
    ... Nobody wrote: ... the last arithmetic operation performed when evaluating a particular ... no assumption about overflow being indicated by a flag, ...
    (comp.lang.c)
  • help!
    ... " An unhandled exception of type 'System.ArithmeticException'occurred in ... Overflow or underflow in the arithmetic operation." ...
    (microsoft.public.dotnet.languages.csharp)
  • help!
    ... " An unhandled exception of type 'System.ArithmeticException'occurred in ... Overflow or underflow in the arithmetic operation." ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Pointers gone mad!
    ... INCBY) so that there's no overflow while evaluating the condition ... a carry - again, recall your elementary school days), and if that too ...
    (microsoft.public.vc.language)