why isn't the 'exit' in the finally end clause executed?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

why isn't the 'exit' in the finally end clause executed?

Dennis
Using fpc 3.0.4, Lazarus 2.0, the following simple program

program tryfinally;

begin
   try
     Writeln('before finally');
   finally
      Writeln('inside finally. Before Exit');
      exit; //<----why isn't it executed?
   end;
   Writeln('after try finally block');

end.


gives


P:\RAM64>tryfinally.exe
before finally
inside finally. Before Exit
after try finally block



I have tried putting the try finally block inside a procedure, the same
happened.
program tryfinally;

procedure Test;
begin
     try
       Writeln('before finally');
     finally
        Writeln('inside finally. Before Exit');
        exit;
     end;
     Writeln('after try finally block');
end;

begin
   Test;

end.

Dennis
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: why isn't the 'exit' in the finally end clause executed?

Jonas Maebe-3
On 23/06/2019 09:08, Dennis wrote:

> Using fpc 3.0.4, Lazarus 2.0, the following simple program
>
> program tryfinally;
>
> begin
>   try
>     Writeln('before finally');
>   finally
>      Writeln('inside finally. Before Exit');
>      exit; //<----why isn't it executed?
>   end;
>   Writeln('after try finally block');
>
> end.

I seem to remember this was a bug in the Win64 SEH support that was
fixed later on, but I can't find the bug report.


Jonas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: why isn't the 'exit' in the finally end clause executed?

Alexander Grotewohl
In reply to this post by Dennis
delphi apparently functions the same if I've read the docs right. something about returning control to the exception handler BEFORE your program gets control back.

--
Alexander Grotewohl
http://dcclost.com

On Jun 23, 2019 3:08 AM, Dennis <[hidden email]> wrote:

Using fpc 3.0.4, Lazarus 2.0, the following simple program

program tryfinally;

begin
  try
    Writeln('before finally');
  finally
     Writeln('inside finally. Before Exit');
     exit; //<----why isn't it executed?
  end;
  Writeln('after try finally block');

end.

gives

P:\RAM64>tryfinally.exe
before finally
inside finally. Before Exit
after try finally block

I have tried putting the try finally block inside a procedure, the same
happened.
program tryfinally;

procedure Test;
begin
    try
      Writeln('before finally');
    finally
       Writeln('inside finally. Before Exit');
       exit;
    end;
    Writeln('after try finally block');
end;

begin
  Test;

end.

Dennis
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal



_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: why isn't the 'exit' in the finally end clause executed?

Free Pascal - General mailing list
In reply to this post by Jonas Maebe-3
Am 23.06.2019 um 16:33 schrieb Jonas Maebe:

> On 23/06/2019 09:08, Dennis wrote:
>> Using fpc 3.0.4, Lazarus 2.0, the following simple program
>>
>> program tryfinally;
>>
>> begin
>>    try
>>      Writeln('before finally');
>>    finally
>>       Writeln('inside finally. Before Exit');
>>       exit; //<----why isn't it executed?
>>    end;
>>    Writeln('after try finally block');
>>
>> end.
> I seem to remember this was a bug in the Win64 SEH support that was
> fixed later on, but I can't find the bug report.
It's still the case on current trunk at least on Win64.

Regards,
Sven
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: why isn't the 'exit' in the finally end clause executed?

Dennis
.
>> I seem to remember this was a bug in the Win64 SEH support that was
>> fixed later on, but I can't find the bug report.
> It's still the case on current trunk at least on Win64.
>

Since it might be a bug, I'd like to search for all occurrences of such
combination in my projects.
How do I find it using regular expression ACROSS line breaks?
That is, how to find the following in Lazarus IDE?

finally
    .....
    exit;
    .....
end;

Thanks in advance.

Dennis
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal