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

Michael Van Canneyt michael at freepascal.org
Sat Mar 2 14:08:07 CET 2013



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.


More information about the Lazarus mailing list