[fpc-pascal] EAccessViolation on wrong exception re-raise: intended behavior?

Michael Van Canneyt michael at freepascal.org
Tue Mar 31 13:26:03 CEST 2015



On Tue, 31 Mar 2015, leledumbo wrote:

> Consider the following program:
>
> {$mode objfpc}
>
> uses sysutils;
>
> begin
>  try
>    try
>      raise exception.create('test');
>    except
>      on e: exception do begin
>        e.message := 'tset';
>        raise e; // correct re-raise should only have raise; no exception
> variable may present
>      end;
>    end;
>  except
>    writeln('oow');
>  end;
> end.
>
> which is a wrong way to re-raise an exception. The program runs but after
> the outer exception handler ('oow'), it ends with EAccessViolation. Is this
> the intended behavior?

I tested in Delphi XE, it also crashes. So, yes it is intended behaviour.

It is not desirable, of course. But there is no way the compiler can decide 
whether the 'raise e' statement is correct.

Michael.



More information about the fpc-pascal mailing list