[fpc-devel] Issue 3.2.3 (ok in 3.3.1) Win64 "raise exception" does not go to "except"

Florian Klämpfl florian at freepascal.org
Sat Jan 15 16:25:38 CET 2022


Am 13.01.2022 um 16:49 schrieb Martin Frb via fpc-devel:
> In the  below code compiled with 3.2.3 (today and early Dec)
> when the exception is reached the app exits.
> 
> There is no code from finally, nor from except block executed.
> 
> The "randomize" is just to put some code into each block. No special meaning otherwise.
> 
> This issue is on Win64. (works for 32 bit Win)
> And appears to be ok in 3.3.1.

It happens only with -O1 or higher, the compiler optimizes away all the exception data (diff between -O- and -O1):

176,180d170
< # [37] end;
<       nop
<       leaq    (%rbp),%rsp
<       popq    %rbp
<       ret
183,195d172
<       .long   3
<       .long   0
<       .rva    .Lj27
<       .rva    .Lj28
<       .rva    P$PROJECT1$_$FOO_$$_fin$00000002
<       .long   0
<       .rva    .Lj22
<       .rva    .Lj23
<       .rva    P$PROJECT1$_$FOO_$$_fin$00000003
<       .long   1
<       .rva    .Lj20
<       .rva    .Lj17
<       .rva    .Lj18
199a177
 > # [37] end;

Maybe Gareth can have a look?

> 
>      program Project1;
>      {$mode objfpc}{$H+}
> 
>      uses SysUtils;
> 
>      var
>        bar: boolean;
> 
>      procedure Foo;
>      begin
>        while true do begin
>          try
>            try
>              try
>                if bar then
>                  raise Exception.Create('');
>                Randomize;
>              finally
>                Randomize;
>                try
>                  Randomize;
>                finally
>                  Randomize;
>                end;
>              end;
>              Randomize;
>            finally
>              Randomize;
>            end;
>            Randomize;
>          except
>            bar := false;
>            Randomize;
>          end;
>        end;
>      end;
> 
>      begin
>        bar := true;
>        Foo;
>      end.
> 
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel



More information about the fpc-devel mailing list