[fpc-pascal] Calling unassigned procedure gives no stack trace with -gl

Tom Verhoeff T.Verhoeff at tue.nl
Thu Jul 14 07:15:57 CEST 2005


On Thu, Jul 14, 2005 at 01:12:23AM +0200, Marcel Martin wrote:
> Tom Verhoeff a écrit :
> >begin
> >  VMyClass := TMyClass.Create;
> >  //VMyClass.FP := VMyClass.P;  { with this assignment, it works }
> >  VMyClass.FP;  { this causes an Access Violation }
> 
> Of course, at this point FP = nil since you didn't set it.

Just in case, I was not understood:

The point is that there is no stack trace with line numbers on the
(obviously correct) exception, in spite of the option -gl (even when
explicitly using SysUtils).

I admit that the comment "it works" is misleading/confusing the issue.
I wrote it that way, to show that the program is otherwise fine, and
that the exception should indeed be a "normal"/correctly raised exception.

This may be a more general problem with SOME KINDS of unhandled exceptions
stack traces/line numbers.  Note that, in the following program, you do
get a stack trace with line numbers:

program AsssertOk;

uses
  SysUtils;

begin
  Assert(False, 'Assertion failed on purpose')
end.

when compiled with options `-Sa -gl', produces as output

An unhandled exception occurred at $0806834E :
EAssertionFailed : Assertion failed on purpose (assert-ok.pp, line 7)
  $0806834E
  $080540D4
  $080480D1  main,  line 7 of assert-ok.pp

That is, you get a stack trace with line numbers.

Without using SysUtils you just get (even if you compile w/o -gl):

Assertion failed on purpose (assert-ok.pp, line 7).

Use of SysUtils "converts" the unhandled exception. (Where is that
documented?)

	Tom
-- 
E-MAIL: T.Verhoeff @ TUE.NL     | Fac. of Math. & Computing Science
PHONE:  +31 40 247 41 25        | Eindhoven University of Technology
FAX:    +31 40 247 54 04        | PO Box 513, NL-5600 MB Eindhoven
http://www.win.tue.nl/~wstomv/  | The Netherlands




More information about the fpc-pascal mailing list