[Lazarus] Assignment on exception (was Re: exception handling in constructor)

Xiangrong Fang xrfang at gmail.com
Sat Mar 2 14:25:12 CET 2013


I guess there is really a bug, see the following:
==============================
  f := 123;
  try
    f := ln(0);
  except
  end;
  //WriteLn(f);
  //{
  if f = 123 then
    WriteLn('f=123, not modified')
  else
    WriteLn('f is modified to:', f);
  //}
===============================

If I just WriteLn(f), it output Nan, I think there is some magic happening
here.

If I try to use if-then on f, then I get:

An unhandled exception occurred at $000000000040028C :
EDivByZero : Division by zero
  $000000000040028C line 18 of project1.lpr


2013/3/2 Michael Van Canneyt <michael at freepascal.org>

>
>
> On Sat, 2 Mar 2013, Xiangrong Fang wrote:
>
>  Hi,
>>
>> Could anyone explain this:
>>
>> Number := 123;
>> try
>>   Number := Ln(0);
>> except
>> end;
>> WriteLn(Number);
>>
>> The output is Nan, not 123. i.e. when exception occurs the variable is
>> modified anyway!  So in the example below assigning MyInstance
>> to nil before Create does not help to ensure it is nil if an exception
>> occurs?
>>
>
> It does, you can test that.
>
> I suspect that the case above is an artifact of the FPU error reporting,
> and it should be filed as a bug.
>
> Michael.
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20130302/cca7fbdb/attachment-0003.html>


More information about the Lazarus mailing list